Skip to content

Commit

Permalink
Added unescaped interpolation variant. Closes #124
Browse files Browse the repository at this point in the history
  • Loading branch information
tj committed Dec 19, 2010
1 parent f46683d commit bbe99ec
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, "'")
+ ") + '";
});
};

Expand Down
1 change: 1 addition & 0 deletions test/jade.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand Down

0 comments on commit bbe99ec

Please sign in to comment.