加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

Smarty PHP与AngularJS冲突

发布时间:2020-12-13 13:13:59 所属栏目:PHP教程 来源:网络整理
导读:当我在同一模板中使用AngularJS时,如何停止Smarty抛出错误.我有一个Smarty页面模板与此代码: li ng-repeat="i in items" p class="item"{{i}}/p /li 当我在浏览器中查看时,我得到一个空白页.我的apache error_log中有一个很大的错误,其中包含以下内容: PHP
当我在同一模板中使用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.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读