i am trying to use smarty variables inside javascript inside tpl
can you suggest me solution please
update: http://pastebin.com/J4ibLz1m
i am trying to use smarty variables inside javascript inside tpl
can you suggest me solution please
update: http://pastebin.com/J4ibLz1m
Simply close the {literal} tag right before inserting the smarty variable, and re-open it again.
Or use {ldelim} and {rdelim} for the pieces of code where you assign values from Smarty.
{literal}
function doSomething(myNumber){
var result = myNumber/{/literal}{$myDivider}{literal};
// rest of code...
}
// more functions...
{/literal}
or
{literal}
function doSomething(myNumber){
{/literal}
var result= myNumber/{$myDivider};
{literal}
// rest of code...
}
// more functions...
{/literal}
or
function doSomething(myNumber){ldelim}
var result= myNumber/{$myDivider};
// rest of code below...
{rdelim}
function doSomeMore(another){ldelim}
alert('{$myHello}');
// more code
{rdelim}