java -jar SoyToJsSrcCompiler.jar --shouldGenerateJsdoc --outputPathFormat
simple.js --srcs simple.soy
SoyToJsSrcCompiler生成一个js文件,该文件是这样的:预编译Closure模板 - 在关闭编译器警告“变量之前声明中引用的”
if (typeof templates == 'undefined') { var templates = {}; }
if (typeof templates.simple == 'undefined') { templates.simple = {}; }
/**
* @param {Object.<string, *>=} opt_data
* @param {(null|undefined)=} opt_ignored
* @return {string}
* @notypecheck
*/
templates.simple.tinyButton = function(opt_data, opt_ignored) {
.....
};
我使用关闭编译器与--warning_level=VERBOSE
和--compilation_level ADVANCED_OPTIMIZATIONS
和我得到这样的警告:
simple.js:1: WARNING - Variable referenced before declaration: templates
if (typeof templates == 'undefined') { var templates = {}; }
如何清除此警告?
尝试:'var templates = templates || {}; templates.simple = templates.simple || {};' – elclanrs
@elclanrs这段代码由SoyToJsSrcCompiler生成。每当模板发生变化时,我都必须对其进行编辑 –