Re: [SMARTY-DEV] smarty custom functions namespaces
[email protected] (Monte Ohrt) Thu, 21 Jul 2005 12:20:53 -0500
| Newsgroups | php.smarty.dev |
|---|---|
| Message-ID | <[email protected]> |
Hi Andrei,
Obviously this namespace syntax won't make it into the Smarty core, but
on the topic of "Every template language evolves until it turns into
PHP"... I take it that you are talking about the template syntax. I
don't think any of Smarty's syntax has evolved in over two years. The
last addition was object method access. We wanted to add this ability
without *any* new syntax, but due to the underlying Smarty code
structure this was inevitable (and there are two ways to handle objects,
one that is more secure and syntax friendly but can't be looped.) Smarty
3 (which is in its initial stages) will likely be making a step toward
resolving some syntax complexities. Example, consolidation of current
syntax where {$foo.bar} could be either access to an array key or an
object method, something the template designer shouldn't be concerned
with. There are also some not-so-great legacy syntax decisions that may
get a cleanup as well.
And of course, the #1 purpose of a template engine (or at least Smarty)
is the separation of application code from its presentation. Smarty is
merely a toolbox to make the presentation assembly as painless as
possible, which is why it is regarded as being a "framework" for
application presentation control, and not just a tag replacement engine.
The templates are an abstraction from the PHP language syntax itself,
something that is safer and easier for a template designer to visualize
and use within embedded HTML tags, and as a bonus they are insulated
from PHP functions and PHP variable namespace.
Anyways, my two cents on the template evolution topic ;)
Monte
Andrei Zmievski wrote:
> Do you people realize that you are proving Rasmus's theorem with every
> such thing? I am speaking of "Every template language evolves until it
> turns into PHP".
>
> -Andrei
>
> On Jul 21, 2005, at 3:19 AM, Michael Davey wrote:
>
>> Hi,
>>
>> I've added a crude form of namespaces to my private copy of Smarty. A
>> template function like:
>>
>> {namespace:test}
>>
>> ...causes the test() function in the smarty_function_namespace class to
>> be called.
>>
>> I'm planning to use this feature in TikiWiki to provide accessor-like
>> template functions to access various data: article::title,
>> article::description and so on. I though that this might be of more
>> general use, so here is a patch for this morning's CVS snapshot of
>> Smarty.
>>
>> --
>> Michael
>> <smarty_namespace_patch.tar.gz>--
>> Smarty Development Mailing List (http://smarty.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>
>