Преглед изворни кода

According to the documentation, & is also an unescaping character.

tags/0.5.0-vsc
thegrandpoobah пре 16 година
родитељ
комит
a83dd64573
4 измењених фајлова са 9 додато и 1 уклоњено
  1. +1
    -0
      examples/unescaped_ampersand.html
  2. +5
    -0
      examples/unescaped_ampersand.js
  3. +1
    -0
      examples/unescaped_ampersand.txt
  4. +2
    -1
      mustache.js

+ 1
- 0
examples/unescaped_ampersand.html Прегледај датотеку

@@ -0,0 +1 @@
<h1>{{&title}}</h1>

+ 5
- 0
examples/unescaped_ampersand.js Прегледај датотеку

@@ -0,0 +1,5 @@
var unescaped_ampersand = {
title: function() {
return "Bear > Shark";
}
};

+ 1
- 0
examples/unescaped_ampersand.txt Прегледај датотеку

@@ -0,0 +1 @@
<h1>Bear > Shark</h1>

+ 2
- 1
mustache.js Прегледај датотеку

@@ -152,7 +152,7 @@ var Mustache = function() {
var that = this; var that = this;


var new_regex = function() { var new_regex = function() {
return new RegExp(that.escaped_otag + "(=|!|>|\\{|%)?([^\\/#\\^]+?)\\1?" +
return new RegExp(that.escaped_otag + "(=|!|>|\\{|&|%)?([^\\/#\\^]+?)\\1?" +
that.escaped_ctag + "+", "g"); that.escaped_ctag + "+", "g");
}; };


@@ -168,6 +168,7 @@ var Mustache = function() {
case ">": // render partial case ">": // render partial
return that.render_partial(name, context, partials); return that.render_partial(name, context, partials);
case "{": // the triple mustache is unescaped case "{": // the triple mustache is unescaped
case "&": // the ampersand is also unescaped
return that.find(name, context); return that.find(name, context);
default: // escape the value default: // escape the value
return that.escape(that.find(name, context)); return that.escape(that.find(name, context));


Loading…
Откажи
Сачувај