Permalink
Browse files

Fix templates with single quotes

  • Loading branch information...
1 parent 4185e46 commit 69ff1cc8fbe74fa64b4e07faa02fd56f46cd22cb @tadzik committed Jun 7, 2012
Showing with 4 additions and 2 deletions.
  1. +2 −1 lib/Template/Mojo.pm
  2. +2 −1 t/00-basic.t
View
3 lib/Template/Mojo.pm
@@ -39,7 +39,8 @@ class Template::Mojo::Actions {
make $<perlexpr>.ast
}
else {
- make sprintf q[;$_M ~= '%s';], $<characters>.Str;
+ make sprintf q[;$_M ~= '%s';],
+ $<characters>.Str.subst(/"'"/, "\\'", :g)
}
}
View
3 t/00-basic.t
@@ -1,6 +1,6 @@
use Test;
use Template::Mojo;
-plan 8;
+plan 9;
sub render($tmpl, *@a) {
Template::Mojo.new($tmpl).render(|@a)
@@ -14,3 +14,4 @@ is render('answer = <%= $^a + $^b %>', 40, 2), 'answer = 42';
is render('hello <% "blarg" %> world'), 'hello world';
is render("% for 1..3 \{\nhello\n% \}\n"), "hello\nhello\nhello\n";
is render("hello\n%# die 'this is an harmless comment'\nworld"), "hello\nworld";
+is render("<a href='foo'>bar</a>"), "<a href='foo'>bar</a>";

0 comments on commit 69ff1cc

Please sign in to comment.