I need to assign data to javascript source. Is it possible to use smarty template without tpl file. Like this...
$sHtml = '
{foreach from=$myArray key=k item=v}
<li>{$k}: {$v}</li>
{/foreach}
';
$arr = array(9 => 'Tennis', 3 => 'Swimming', 8 => 'Coding');
$oSmarty = new smarty();
$oSmarty->assign('myArray', $arr);
$result = $oSmarty->fetch($sHtml);
echo $result;
Return like this...
<li>9: Tennis</li>
<li>3: Swimming</li>
<li>8: Coding</li>