Jade.escape is undefined on compiled Jade template

☆樱花仙子☆ 提交于 2019-12-11 13:39:07

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!