Re: Re: Templating engines

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

 



* Rasmus Lerdorf <rasmus@xxxxxxxxxxx> :
> My main issue with general-purpose templating systems is that they 
> always end up inventing a new language.  It may start off as a subset of 
> some other language, but eventually it turns into a new language.  In 
> Smarty, for example, you now have stuff like:
>
>    {object-> method p1="arg1" p2=$arg2 assign="output"}
>    Result was {$output}
>
> I fail to see how this is in any way better/easier/superior to:
>
>    <?$output = $object-> method("arg1",$arg2)?>
>    Result was <?=$output?>
>
> As far as I am concerned you shouldn't be dealing with any sort of 
> objects from a template to begin with.  There should be nothing but 
> simple variables and straight function calls from a template, but this 
> is a religious issue that people will never agree on.  Hence PHP's 
> neutral approach where the exact templating delienation is left up to 
> the users.

I thoroughly agree with you on this point. I think in some areas of
Smarty development, they've gotten a little too complex, likely as a
result of people getting lazy in what they send to the template and
requesting new features. That said, I still use Smarty -- but I try to
send it straight scalars or arrays, as you suggest above, leaving my
heavy lifting in my application logic, and keep the presentation logic
more lightweight.

In reading "The Pragmatic Programmer," I think that templating languages
are an application of using metadata or a domain language. The principle
here is a subset of the language -- or another language entirely that
can be interpreted by the original language -- helps to contain and
solve the problem. Sometimes it's easier to use the subset to describe
the process than the full language. 

Let's face it, there's over 1000 functions in PHP; most of the time, I
only need a few of those for my display logic. Using a template engine
and its language helps me switch gears in my brain to thinking in terms
of display instead of my application logic.

-- 
Matthew Weier O'Phinney           | WEBSITES:
Webmaster and IT Specialist       | http://www.garden.org
National Gardening Association    | http://www.kidsgardening.com
802-863-5251 x156                 | http://nationalgardenmonth.org
mailto:matthew@xxxxxxxxxx         | http://vermontbotanical.org

-- 
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