Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added unescaped interpolation variant. Closes #124

  • Loading branch information...
commit bbe99ec592ebc6e326afa23a02128575a8f262e7 1 parent f46683d
@tj tj authored
Showing with 6 additions and 2 deletions.
  1. +5 −2 lib/utils.js
  2. +1 −0  test/jade.test.js
View
7 lib/utils.js
@@ -14,10 +14,13 @@
*/
var interpolate = exports.interpolate = function(str){
- return str.replace(/(\\)?[#$]{(.*?)}/g, function(str, escape, code){
+ return str.replace(/(\\)?([#$!]){(.*?)}/g, function(str, escape, flag, code){
return escape
? str
- : "' + escape(" + code.replace(/\\'/g, "'") + ") + '";
+ : "' + "
+ + ('!' == flag ? '' : 'escape')
+ + "(" + code.replace(/\\'/g, "'")
+ + ") + '";
});
};
View
1  test/jade.test.js
@@ -324,6 +324,7 @@ module.exports = {
assert.equal('yo, \'jade\' is cool\n', render('| yo, #{name || "\'jade\'"} is cool', { locals: { name: null }}));
assert.equal('yo, jade is cool\n', render('| yo, ${name || \'jade\'} is cool', { locals: { name: null }}));
assert.equal('foo &lt;script&gt; bar\n', render('| foo #{code} bar', { locals: { code: '<script>' }}));
+ assert.equal('foo <script> bar\n', render('| foo !{code} bar', { locals: { code: '<script>' }}));
},
'test invalid indentation multiple': function(assert){
Please sign in to comment.
Something went wrong with that request. Please try again.