applying smarty recursively?
| From: | Henry Grech-Cini | Date: | Tue, 06 Apr 2004 12:15:22 +0000 |
| Subject: | applying smarty recursively? | ||
| Groups: | php.smarty.general | ||
| Request: | Send a blank email to php-smarty-general+get-11234@lists.php.net to get a copy of this message | ||
Hi All,
I have an intermediate smarty notation which I need to render using smarty
twice.
For example
I have the following "base" template;
{literal}
Hi all today's date is {/literal}{date format="%A, %B, %e, %Y"}{literal}.
And that's that
{/literal}
I have designed a date plug-in to handle this and it translates it the
standard smarty as follows;
{literal}
Hi all today's date is {/literal}{$smarty.now|date_format:"%A, %B, %e,
%Y"}{literal}. And that's that
{/literal}
The reason I do this is because I want to be able to translate it to other
formats should the need arise. i.e.
Hi all today's date is <?php strftime("%A, %B, %e, %Y"); ?>. And that's
that
The use of literals is to guard against JavaScript etc. using curly braces
confusing smarty.
My question is what is the best way to apply smarty twice can it be achieved
through the use of resources?
Namely can I define a resource "assigned" that accesses Smarty variables and
do something like this.
{include file="source.tpl.html" assign="firstpass"}
{include file="assigned:firstpass" assign="secondpass"}
{$secondpass}
where "source.tpl.html" contains the original "base" template.
Or is there a better way?
Thanks