小胡子:全局禁用html转义? [英] Mustache: Globally disable html escaping?

查看:89
本文介绍了小胡子:全局禁用html转义?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法(不修改胡须来源)禁用HTML转义?我正在使用小胡子做其他事情并且不想让以下实体转义。

Is there a way how I can (without modifying the sources of mustache) disable the HTML escaping? I'm using mustache for other things and dont want to have the following entities escaped.

var entityMap = {
  "&": "&",
  "<": "&lt;",
  ">": "&gt;",
  '"': '&quot;',
  "'": '&#39;',
  "/": '&#x2F;'
};

给定模板如 foo'{{bar}}'并且视图 {bar:1} 将生成 foo&#39; 1&#39

Given a template like foo '{{bar}}' and a view { bar : 1 }will produce foo &#39;1&#39.

推荐答案

实际上很简单,小胡子提供转义要覆盖的函数。以下行禁用转义小胡子模板。

It's actually pretty simple, mustache is offering the escape function to be overridden. The following line disables the escaping of mustache templates.

mustache.escape = function (value)
{
    return value;
};

这篇关于小胡子:全局禁用html转义?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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