答案如果您使用您的模板wp.template你可以找到你的答案here
如果您可以直接在JS使用下划线的模板文件,你应该改变模板设置是这样的:
/*
* Underscore's default ERB-style templates are incompatible with PHP
* when asp_tags is enabled, so your template uses Mustache-inspired templating syntax.
*
* Make the underscore template like wp.template function
*
*/
var templateSettings = {
evaluate : /<#([\s\S]+?)#>/g,
interpolate : /\{\{\{([\s\S]+?)\}\}\}/g,
escape : /\{\{([^\}]+?)\}\}(?!\})/g,
variable : 'data'
};
var innerGizmoTemplate = '<div class="{{ data.className }}">'
+ ' <# _.each(data.params, function(param){ #>'
+ ' <div class="karma-builder-gizmo-{{ param.type }} {{ param.className }} ">'
+ ' <# if("icon" === param.type){ #>'
+ ' <div>{{{ param.icon }}}</div>'
+ '<# } else if("text" === param.type) {#>'
+ '<div>{{{ param.value }}}</div>'
+ '<# } #>'
+ '</div>'
+ '<# }) #>'
+ '</div>' ;
// then get it easily like this
var compiled = _.template(innerGizmoTemplate, templateSettings);
console.log(compiled(YourParams));
禁用此功能:http://php.net/manual/en/ini.core.php#ini.asp-tags – 2014-10-27 12:55:49
你是什么意思“php正在使用<%like”?就像它将'<?php'转换为'<%',或者默认使用asp标签?另外'var src;'看起来不像有效的PHP,是underscorejs的一部分吗? – 2014-10-27 12:56:08
感谢@SergiuParaschiv我试图找到PHP文档在这个信息,但看到了,我没有做一个很好的搜索。 – nicearma 2014-10-27 13:00:11