Echo or Print Javascript using Smarty variable

Hi,

I want to know how to show javascript using smarty variable.

$jscode ="
<script>
alert('hi');
</script>

";
assign('CODE',$jscode)

In smarty file

{$CODE}

Currently it shows javascript code instead executing it.

Any Idea?

-Thanks

Probably you have auto escaping turned on. Try the nofilter modifier.

Thanks :slight_smile:

This solution works.

{$CODE|escape nofilter}

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.