Eval Smarty Code inside a Smarty Template
is there a way to evaluate Smarty Code inside an existing Smarty template? For example, I may have the following construct:
smartyTemplate.tpl
<body>
<div id="dynamicPart">
{$valueFromDatabase}
</div>
</body>
Whereas the Smarty variable $valueFromDatabase contains another Smarty Template which I would like to be inserted in place of the variable and then evaluated as a开发者_StackOverflow社区 template (with all the logic expressions in replacements neccessary).
without a custom resource, you could have just used an {include file="your/template.tpl"}. Or render the template from the database in code using $smarty->fetch("your/template.tpl") and assigning that to $valueFromDatabase.
{eval var=$valueFromDatabase}
will work
精彩评论