Re: [SMARTY-DEV] Re: Intelligent JavaScript handling

From: Date: Fri, 19 Mar 2004 14:32:07 +0000
Subject: Re: [SMARTY-DEV] Re: Intelligent JavaScript handling
References: 1 2 3  Groups: php.smarty.dev 
Request: Send a blank email to php-smarty-dev+get-2226@lists.php.net to get a copy of this message
Here's a prefilter function i've found and modified a little. It do the job perfectly for us function smarty_prefilter_literal_script(&$tpl_source, &$smarty) { // Put {literal}{/literal} tag automaticaly, unless you specify <script ... smarty>...</script> $pattern[] = '~<script\b(?![^>]*smarty)(.*)</script>~siU'; $replace[] = '<!-- {literal} --><script$1 $2</script><!-- {/literal} -->'; return preg_replace($pattern, $replace, $tpl_source); } The same for <style> tags function smarty_prefilter_literal_style(&$tpl_source, &$smarty) { $pattern[] = '~<style\b(?![^>]*smarty)>(.*)</style>~siU'; $replace[] = '<!--{literal}--><style$1>$2</style><!--{/literal}-->'; return preg_replace($pattern, $replace, $tpl_source); } // function Hope it will help you. Rémy Dufour

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