Jade.escape 在编译的 Jade 模板上未定义 [英] Jade.escape is undefined on compiled Jade template

查看:43
本文介绍了Jade.escape 在编译的 Jade 模板上未定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经编译了一个玉模板,如:

I've compiled a jade template like:

jade --client --no-debug ...

然后在客户端包含 jade.js 和编译的模板文件.但是 jade.escape 是未定义的.我注意到编译后的模板函数看起来像:

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

然后我像这样使用它:

html = anonymous({title: "Hello World!"})

但这意味着逃逸将是未定义的?我注意到 jade.escape 也是未定义的,尽管我包含了 jade.js

But it means escape will be undefined? I notice jade.escape is also undefined although I included jade.js

推荐答案

为了与 jade.escape 一起工作,您需要将 runtime.js 与 jade.js 一起添加.

you need to add runtime.js along with jade.js inorder to work with jade.escape.

这篇关于Jade.escape 在编译的 Jade 模板上未定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆