Intelligent JavaScript handling

From: Date: Wed, 17 Mar 2004 16:27:18 +0000
Subject: Intelligent JavaScript handling
Groups: php.smarty.dev 
Request: Send a blank email to php-smarty-dev+get-2216@lists.php.net to get a copy of this message
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

« previous php.smarty.dev (#2216) next »