开发者

Eval Smarty Code inside a Smarty Template

开发者 https://www.devze.com 2022-12-20 22:21 出处:网络
is there a way to evaluate Smarty Code inside an existing Smarty template? For example, I may have the following construct:

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

0

精彩评论

暂无评论...
验证码 换一张
取 消