Permalink
Browse files

fix attr interpolation escaping. Closes #771

  • Loading branch information...
1 parent 1aea1dd commit 2641ae8a9b44189e5ec2d0f9d8523527004a8ad6 @tj tj committed Sep 24, 2012
Showing with 8 additions and 4 deletions.
  1. +4 −2 lib/lexer.js
  2. +2 −1 test/cases/attrs.interpolation.html
  3. +2 −1 test/cases/attrs.interpolation.jade
View
@@ -504,8 +504,10 @@ Lexer.prototype = {
}
function interpolate(attr) {
- return attr.replace(/#\{([^}]+)\}/g, function(_, expr){
- return quote + " + (" + expr + ") + " + quote;
+ return attr.replace(/(\\)?#\{([^}]+)\}/g, function(_, escape, expr){
+ return escape
+ ? _
+ : quote + " + (" + expr + ") + " + quote;
});
}
@@ -1 +1,2 @@
-<a href="/user/5"></a>
+<a href="/user/5"></a>
+<foo bar="stuff #{here} yup"></foo>
@@ -1,2 +1,3 @@
- var id = 5
-a(href='/user/#{id}')
+a(href='/user/#{id}')
+foo(bar='stuff \#{here} yup')

0 comments on commit 2641ae8

Please sign in to comment.