Re: Assign param (was: Re: counter as a variable)
| From: | Anders Janson | Date: | Mon, 26 Nov 2001 09:52:56 +0000 |
| Subject: | Re: Assign param (was: Re: counter as a variable) | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-2043@lists.php.net to get a copy of this message | ||
Ivo Jansch wrote:
> Hi,
>
> Monte Ohrt wrote:
>
> > Maybe we could add a new attribute to counter:
> > {counter assign="varname"}
>
> A very nice idea. There are some other tags that could use an assign
> attribute as well.
>
> Assign could be implemented at a 'higher level'. Instead of handling it
> in the tag handler functions, you could have it parsed by the Smarty
> core. If there's an assign attribute to a tag, Smarty will assign the
> result of the tag to a variable, instead of outputting it. This way, any
> tag will have assign support.
>
ANY tag?
{strip assign=foo} ??
{elseif assign=blaah}....
Naah, doesn't make sense! Some custom functions could benefit from having
an assign attribute, but I don't think the core functions need it. Perhaps
this is also what you meant to say (then, sorry! :) ) ?
Interesting idea, however. Probably not too difficult to implement either.
The core could turn output buffering on for custom functions when the
assign attribute is specified, and capture the output.
Just brainstorming here, but how about an option for capturing custom
function output, and recursively handle it as template code? Kind of a
macro functionality? Very similar to the include tag, but the code would
not be fetched from a file. The template source could be made dynamic.
Just the usual $ 0.02 :-)
/Anders