我刚刚遇到一个问题:模板中的smarty sintaxis在{}之间,而且jquery移动组件之一使用{}进行onw,所以我从smarty那里得到了一个错误。这个问题有解决办法吗?
<input name="mydate" id="mydate" type="date" data-role="datebox" data-options='{"mode": "calbox"}'>
使用{literal}
标签:
<input ... data-options='{literal}{"mode": "calbox"}{/literal}'>
如果您使用smarty 3,只需在{}:之间留出空格
<input name="mydate" id="mydate" type="date" data-role="datebox" data-options='{ "mode": "calbox" }'>
请参阅http://www.smarty.net/v3_overview在"(Javascript)Auto Escapement"下
您也可以使用{rdelim}
和{ldelim}
作为替代方案。如果你想把js和smarty混合在一起,我觉得它特别有用。它们将被smarty替换为大括号,并且您仍然可以在它们之间使用smarty代码,但使用{literal}
时情况并非如此。你的样品看起来像这样:
<input name="mydate" id="mydate" type="date" data-role="datebox" data-options='{ldelim}"mode": "calbox"{rdelim}'>