Re: Template class
| From: | Wolfram Kriesing | Date: | Tue, 11 Dec 2001 12:21:24 +0000 |
| Subject: | Re: Template class | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-3447@lists.php.net to get a copy of this message | ||
> What's the point of something like this? Just to type { instead of
> <? doesn't seem like any sort of benefit to me.
it does not only.
please have a look in the template
http://wolfram.kriesing.de/libs/php/examples/SimpleTemplate/index.ph
p (there you have links to the code/template/class)
and i think most of the advantages are obvious
first thing: code is better readable, because of proper indention,
which has to be! and the 'ugly' php-tags inside html are gone
the problem i had with smarty or IT[X] was:
smarty:
- i couldnt easily use a value of an array as an index for
referencing a value of another array, now i can
- and for using some custom method (like translating every text) i
would have to write a modifier or my own tag or whatever it was
called - smarty was simply giving me a new 'language' to fill the
template which is not as powerful as php (or as i needed it) so i
had to 'work around' it in the php, which blew up the code there
unnecessarily
IT[X]
- didnt have something like 'if' (conditional blocks), i had to use a
<!-- block --> around it and watch out that inside the block none of
the global variables is written, or the block would be shown anyway
both
- and what else bothered me, was that every variable i wanted to show
in the template i had to assign, it was overhead in my eyes it doesnt
do anything then passing the one varibale to another, and if that is
for the reason of preventing access to certain variables then: i dont
need it
this piece of code looks much nicer, than having the php-tags in
there which in my eyes made the html very unreadable, just to close
a '{' i would need <?php } ?>, bothered me at least
{if(sizeof($disadvantages))}
{foreach($disadvantages as $aDisadvantage)}
<li>{$aDisadvantage}</li>
{else}
no disadvantages registered yet :-)
(well, sorry but i like the python style and i think ommitting
unnecessary stuff makes life easier)
i can apply filters just as smarty ...
if you find it useless ... ok with me
what is/are a major feature(s) that it lacks, that a standard
template system has?
in general: i just wanted to share it, in case someone finds it
useful
--
Wolfram