解决css和js的{}与smarty定界符冲突问题的两种方法

时间:2013-09-10    点击:150   
当输入url地址后网页出现:Fatal error: Uncaught exception 'SmartyCompilerException' with message 'Syntax Error in template "E:\wamp\www\cms\system/templates/index.html" on line 79 "$("#job").load("./system/templates/touch/test.php",{catid:3});" - Unexpected ":", expected one of: "}" , " "' in E:\wamp\www\cms\system\Smarty\sysplugins\smarty_internal_templatecompilerbase.php on line 441这样的问题,通常是css和js的{}与smarty定界符冲突导致的。

解决办法有两个:

1.可以把 smarty 的定界符设成 <{ }>
复制代码 代码如下:

$tpl->left_delimiter = '<{';
$tpl->right_delimiter = '}>';

2.对于js的{}与smarty定界符冲突,可以用smarty的literal处理,可以把JS代码包含在{literal}{/literal}之间就可以了。
复制代码 代码如下:

<{literal}>
$ (
<span style="white-space:pre"> </span>function () { alert ('培训课程')}
);
<{/literal}>
extjs render 用法介绍
用javascript判断IE版本号简单实用且向后兼容
js open() 与showModalDialog()方法使用介绍
jquery获取子节点和父节点的示例代码
解决Jquery load()加载GB2312页面时出现乱码的两种方案
> 返回     
地址:上海市普陀区胶州路941号长久商务中心 电话: QQ:
© Copyright 2012 上海网络 Product All Rights Reserved