问题
I've compiled a jade template like:
jade --client --no-debug ...
Then on client side included jade.js
and the compiled template file. But jade.escape is undefined. I notice the compiled template function looks like:
function anonymous(locals, attrs, escape, rethrow, merge) {
attrs = attrs || jade.attrs; escape = escape || jade.escape; rethrow = rethrow || jade.rethrow; merge = merge || jade.merge;
var buf = [];
with (locals || {}) {
var interp;
buf.push('<h1>');
var __val__ = title
buf.push(escape(null == __val__ ? "" : __val__));
buf.push('</h1>');
}
return buf.join("");
}
Notice how escape is passed in as a parameter. So how might the expected usage be like?
Suppose I have a very simple template:
h1= title
Then I use it like:
html = anonymous({title: "Hello World!"})
But it means escape will be undefined? I notice jade.escape is also undefined although I included jade.js
回答1:
you need to add runtime.js along with jade.js inorder to work with jade.escape.
来源:https://stackoverflow.com/questions/13814153/jade-escape-is-undefined-on-compiled-jade-template