Smarty PHP与AngularJS发生冲突

编程入门 行业动态 更新时间:2024-10-27 10:31:38
本文介绍了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发生冲突

本文发布于:2023-10-22 09:20:45,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1517100.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:发生冲突   Smarty   PHP   AngularJS

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!