Re: [SMARTY-DEV] Intelligent JavaScript handling
| From: | Monte Ohrt | Date: | Wed, 17 Mar 2004 16:33:26 +0000 |
| Subject: | Re: [SMARTY-DEV] Intelligent JavaScript handling | ||
| References: | 1 | Groups: | php.smarty.dev |
| Request: | Send a blank email to php-smarty-dev+get-2217@lists.php.net to get a copy of this message | ||
Another option is replacing "{" with "{ldelim}" and "}" with
"{rdelim}",
since that wasn't mentioned. There usually aren't too many of them, one
pair per javascript function or css definition.
On Wed, 2004-03-17 at 10:27, Mark Rogers wrote:
> The issue of intelligent JavaScript / CSS handling keeps coming up - there
> must be a better way to do it than dropping into and out of
> {literal}{/literal} blocks.
>
> I've not played with filters so I'll make a couple of suggestions first and
> then have a crack at producing something useful if someone can point me in
> the right direction.
>
> It strikes me that what we need is to handle something like:
> {script}
> function somefunc() {
> {if $x==$y}
> var x = {$y};
> {/if}
> }
> {/script}
>
> For this to work, the main criteria inside the {script}{/script} block is
> that { followed by whitespace, or } preceded by it, should be handled
> literally, otherwise it should be seen as Smarty code.
>
> This would seem a reasonable compromise; the braces do not *need* to be
> surrounded by whitespace to make them valid JavaScript/CSS, but could be in
> order to distinguish them from Smarty code. Likewise, I assume that
> whitespace is not illegal in Smarty tags (correct?) but I'd sacrifice that
> to make script handling easier.
>
> Are there any obvious problems with this? What is the correct place to
> implement it? I guess a pre-filter which turns braces accompanied by
> whitespace to (eg) {literal}{{/literal}?
>
> --
> Mark Rogers,
> More Solutions Ltd :: Tel: 0845 45 89 555