Re: templating engine options

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 5/25/09 10:04 AM, "Stuart" <stuttle@xxxxxxxxx> wrote:

> Quick question, how would you implement the following using your
> XML-based template syntax...
> 
> <div class="option <?php if (!empty($option_class)) { echo
> $option_class; } ?>"> ... </div>
> 
> It's worth noting that I'm simply suggesting a different way of
> looking at the world. If you have a templating system you're happy
> with then feel free to continue using it, but I'd encourage you to
> take the time to consider whether it actually gives you any tangible
> benefits. I've used Smarty as well as a number of proprietary
> templating systems and I'm yet to come across one that can justify its
> existence over simply using PHP.
> 
> It's also worth noting that when I refer to a "templating system" I
> mean something that introduces an extra step when running a template.
> I consider the template classes I use to be a templating system but
> they do nothing but formalise the process of passing data to other PHP
> scripts and providing utility functions for them to use.

revisiting the template question is interesting. i'm grateful for this
discussion.

as far as your question goes, with phplib-template, i'd do:

<div class="option {option_class}"> ... </div>

and in the php it is:

$t->setVar('option_class', empty($option_class) ? '' : $option_class);

or some equivalent code. $t is the template object.

the interesting part is trying to explain why i like this better than your
method. perhaps it's because it reduces the page assembly task to a sequence
of regexp replacements and i'm more comfortable with that than i am with
passing variable state to an included php file. why would i be? maybe i'm
more comfortable looking at the world as nothing but strings and in this
world, manipulating them is my job.

there's certainly something i like about not having any php in my html
templates but i can't say exactly what.

i don't think i could come up with better justifications for my current
methods without trying our the alternatives for a decent period. 



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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux