Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add newline escapes

  • Loading branch information...
commit 237a1fde06578ddb7ca291a48758fe36225f22e2 1 parent b8d1677
@tj tj authored
Showing with 8 additions and 2 deletions.
  1. +2 −1  lib/minstache.js
  2. +6 −1 test/index.js
View
3  lib/minstache.js
@@ -49,7 +49,8 @@ function compile(str) {
}
}
- js = escape + '; return ' + js.join('');
+ js = js.join('').replace(/\n/g, '\\n');
+ js = escape + '; return ' + js;
return new Function('obj', js);
}
View
7 test/index.js
@@ -21,6 +21,11 @@ describe('{{id}}', function(){
mm('hi {{name.first}} {{name.last}}.', user).should.equal('hi tobi ferret.');
})
+ it.only('should escape newlines', function(){
+ var user = { name: 'tobi' };
+ mm('hi,\nhow are you {{name}}?', user).should.equal('hi,\nhow are you tobi?');
+ })
+
it('should only match words', function(done){
try {
mm('hi {{name)}}.');
@@ -29,4 +34,4 @@ describe('{{id}}', function(){
done();
}
})
-})
+})
Please sign in to comment.
Something went wrong with that request. Please try again.