Smarty PHP与AngularJS发生冲突 [英] Smarty PHP clashing with AngularJS

查看:151
本文介绍了Smarty PHP与AngularJS发生冲突的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在同一模板中使用AngularJS时,如何阻止Smarty抛出错误。我有一个包含以下代码的Smarty页面模板:

How do I stop Smarty throwing an error when I'm using AngularJS in the same template. I have a Smarty page template with this code:

 <li ng-repeat="i in items">
      <p class="item">{{i}}</p>
 </li>

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

And I'm getting a blank page when I view in a browser. I get a big error in my apache error_log, which contains the following:

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

如果我将 {{i}} 换成 {{4}} 或其他任何数字都可以正常使用。我也可以使用数学,{{8 + 2}}会在页面中显示10个。这是Smarty做数学的吗? angularJS?

If I swap {{i}} for {{4}} or any other digit it works fine. And I can use maths as well, {{8+2}} will show 10 in the page. Is that the Smarty doing the maths of the angularJS?

推荐答案

试试这个:

<li ng-repeat="i in items">
    <p class="item">{literal}{{i}}{/literal}</p>
</li>

来自Smarty网站的报价......

Quote from Smarty site...


{literal}标签允许从字面上获取一个数据块。这是
通常用于Javascript或样式表块,其中{curly
大括号}会干扰模板分隔符语法。{literal} {/ literal}标签内的任何
都不会被解释,但是按原样显示

{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.

这篇关于Smarty PHP与AngularJS发生冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆