[英]How to insert json string into smarty template?
I prepare json string in php file 我在php文件中准备json字符串
$groups_json = json_encode($groups);
$smarty->assign('groups', $groups_json);
How can I put it properly into in .tpl file like that 我该如何正确地将其放入.tpl文件中?
<script>
var groups = "{$groups}"; // <-- here
I have smarty 3 我有聪明人3
My issue was that smarty converted quotes and other stuff to html entities. 我的问题是,聪明地将引号和其他内容转换为html实体。 The answer is to add nofilter parameter to the template variable
答案是将nofilter参数添加到模板变量
var groups = {$groups nofilter};
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.