I am writing a PHP-Script which assigns some html-code to my templates.
PHP-File:
$smarty->assign("PLACEHOLDER", getCode());
$smarty->display('index.html');
function getCode(){
return "{literal}some code which I want to get evaluated ...{/literal}";
}
HTML-File:
{$PLACEHOLDER}
I know i could use {eval var=$PLACEHOLDER}
instead of {$PLACEHOLDER}
which would work perfectly, the only thing is that I have about 500 templates and I won't change the html-code of all of them. Is there a way I can evaluate the code directly when I assign it to the template?
use {eval}
{eval} is used to evaluate a variable as a template. This can be used for things like embedding template tags/variables into variables or tags/variables into config file variables.
If you supply the assign attribute, the output of the {eval} function will be assigned to this template variable instead of being output to the template.
So in your HTML-File use the following:
{eval var=$PLACEHOLDER}