您的位置:首页 > Web前端 > CSS

如何解决css和js的{}与smarty定界符冲突的问题

2013-09-10 13:32 543 查看
当输入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.可以用smarty的literal处理,可以把JS代码包含在{literal}{/literal}之间就可以了。

{literal}
$ (
function () { alert ('培训课程')}
);
{/literal}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: