Bluehost.com Web Hosting $6.95

RE: [PHP] BTML 2.0 released!!!

This is a discussion on RE: [PHP] BTML 2.0 released!!! within the PHP General forums, part of the PHP Programming Forums category; Agreed, and the flexibility of smarty allows for quite a bit more functionality for the template developer... Anyone seriously considering ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 11-09-2003
Javier Muniz
 
Posts: n/a
Default RE: [PHP] BTML 2.0 released!!!

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:chris@wildcharacters.com]
Sent: Thursday, November 06, 2003 3:13 PM
To: Bas; php-general@lists.php.net
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:famde.jong@home.nl]
Sent: Thursday, November 06, 2003 7:21 AM
To: php-general@lists.php.net
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
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 04:53 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0