Agreed, and the flexibility of smarty allows for quite a bit more
functionality for the template developer... Anyone seriously considering
template engines should take a hard look at Smarty.

Just my $0.02.

Oh, and if you don't like top-posting, ignore this msg, as I will
undoubtedly ignore your response (actually I won't even have the chance, I
have at this point configured my anti-spam software to automatically delete
msgs with "top post" or "bottom post" in them, and suggest that other users
of this list do the same).

-Javier

-----Original Message-----
From: Chris Hubbard [mailto:[EMAIL PROTECTED] 
Sent: Thursday, November 06, 2003 3:13 PM
To: Bas; [EMAIL PROTECTED]
Subject: RE: [PHP] BTML 2.0 released!!!


Bas,
Looks interesting.  But why would I use bhtml when I've got Smarty and
10,000 other templating systems to choose from? I'm not interested in the
vauge promises of speed.  I'm only interested in systems that make it easier
for me to code.  Smarty makes it easier for me to code.  How does bhtml help
me?

And ditto on the comments about posting code.  Please find a way to make it
readable. Chris

-----Original Message-----
From: Bas [mailto:[EMAIL PROTECTED]
Sent: Thursday, November 06, 2003 7:21 AM
To: [EMAIL PROTECTED]
Subject: [PHP] BTML 2.0 released!!!


Okay, i am happy that BTML 2.0 is released(finally)

It is also known as BTML Template Edition.

The 3 files(the parser, a simple template and a test BTML-file)

btmltpl.php
---
<?php

function tpl2html($title, $images, $text, $tplfile = "simple.tpl", $links =
"") {

$tpldata = file_get_contents($tplfile);

$trans = array('<%title%>' => $title, '<%text%>' => $text, '<%images%>' =>
$images, '<%links%>' => $links);

$html = strtr($tpldata, $trans);

return $html;

}

function parseTags($file) {

/* readfile... here */

$filedata = file_get_contents($file);

$tag_match =("!<bttag=(\w*)>\s*(.*?)\s*</bttag>!is");

preg_match_all($tag_match, $filedata, $matches);

for ($i=0; $i< count($matches[0]); $i++) {

$tagname = $matches[1][$i];

$tag['tagname'] = $tagname;

$tag['value'] = $matches[2][$i];

$tags[] = $tag;

}

return $tags;

}

include_once "template.php";

$filename = $_GET['name'];

$bttags = parseTags($filename);

// echo "<HTML><HEAD>";

foreach($bttags as $tag) {

switch($tag['tagname']) {

case 'title':

$title = $tag['value'];

// echo "<TITLE>" . $tag['value'] . "</TITLE></HEAD><BODY>";

// echo "<H1>" . $tag['value'] . "</h1><br>";

break;

case 'heading':

$completetext .= "<h1>" . $tag['value'] . "</h1><br>";

// echo "<H1>" . $tag['value'] . "</h1><br>";

break;

case 'image':

if (!empty($tag['value'])) {

// echo "<IMG SRC=\"" . $tag['value'] . "\">";

$images .= "<IMG SRC=\"" . $tag['value'] . "\"><br>";

}

break;

case 'text':

// echo nl2br($tag['value']);

$completetext .= nl2br($tag['value']);

break;

case 'nl':

// echo "<br>\n";

$completetext .= "<br>";

break;

case 'template':

$templatefile = $tag['value'];

break;

case 'link':

$links .= "<a href=" . $tag['value'] . ">" . $tag['value'] . "</a><br>"

}

}



// echo "</body></html>";

if (empty($templatefile)) {

echo tpl2html($title, $images, $completetext);

} else {

echo tpl2html($title, $images, $completetext, $templatefile);

}

?>

---

simple.tpl

---

<HTML>

<HEAD><TITLE><%title%></TITLE></HEAD>

<BODY>

<center><h1><%title%></h1></center><br>

<hr>

<%text%><br><br>

Images: <br>

<%images%>

</BODY>

</HTML>

---

And test.btm

---

<bttag=title>

Welcome to BTML page v1!

</bttag>

<bttag=text>

Welcome to my BTML page!!! This is an experimentally version of HTML!!!

<br>Bye!!!

</bttag>

<bttag=nl>

</bttag>

<bttag=heading>

Bye!!!!

</bttag>

---



Hope that you like it and please tell me wat you think of it,





Bas

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to