diff --git a/lib/util.js b/lib/util.js index 06df4f7..3e09040 100644 --- a/lib/util.js +++ b/lib/util.js @@ -13,8 +13,8 @@ double quoted string with double quotes escaped. Usage: interpolate(JSON.stringify(some_string) ) */ exports.interpolate = function interpolate(str) { - return str.replace(/(\\)?#{(.*)}/g, function(match, escaped, code) { - return escaped ? str : "\"+((__.z=" + code.replace(/\\"/g, '"') + + return str.replace(/(\\)?#{([^}]*)}/g, function(match, escaped, code) { + return escaped ? match : "\"+((__.z=" + code.replace(/\\"/g, '"') + ") == null ? '' : __.z)+\""; }); }; diff --git a/test/output/interpolate.html b/test/output/interpolate.html new file mode 100644 index 0000000..af38d82 --- /dev/null +++ b/test/output/interpolate.html @@ -0,0 +1,5 @@ +

The author of Blade is Blake Miner

But no one really cares much +I dunno because Jade is cool, too. I don't hate. +Jade is cool, too. I don't hate. +and because \#{escaped} +and because TJ is the freakin' man, and everyone should know it

\ No newline at end of file diff --git a/test/templates/interpolate.blade b/test/templates/interpolate.blade new file mode 100644 index 0000000..02475e3 --- /dev/null +++ b/test/templates/interpolate.blade @@ -0,0 +1,6 @@ +p The author of Blade is #{author} +p But no one really cares much + | I dunno #{why} #{Jade} + | #{Jade} + | and because \#{escaped} + | and because TJ is #{TJ}