Smarty PHP与AngularJS冲突

前端之家收集整理的这篇文章主要介绍了Smarty PHP与AngularJS冲突前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
当我在同一模板中使用AngularJS时,如何停止Smarty抛出错误.我有一个Smarty页面模板与此代码
<li ng-repeat="i in items">
      <p class="item">{{i}}</p>
 </li>

当我在浏览器中查看时,我得到一个空白页.我的apache error_log中有一个很大的错误,其中包含以下内容

PHP Fatal error: Uncaught exception 'SmartyCompilerException' with message 'Syntax Error in template ... <p>{{i}}</p>; unknown tag "i

如果我{{i}} {{4}}或任何其他数字互换,它可以正常运作.我也可以使用数学,{{8 2}}将在页面显示10. Smarty是否在做数学运算?

尝试这个:
<li ng-repeat="i in items">
    <p class="item">{literal}{{i}}{/literal}</p>
</li>

从Smarty网站报价…

{literal} tags allow a block of data to be taken literally. This is typically used around Javascript or stylesheet blocks where {curly braces} would interfere with the template delimiter Syntax. Anything within {literal}{/literal} tags is not interpreted,but displayed as-is.

原文链接:https://www.f2er.com/php/131245.html

猜你在找的PHP相关文章