当我在同一模板中使用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发生冲突
发布评论