微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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.jb51.cc/php/131245.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐