Permalink
Browse files

fix bug that disallowed single "{"s to appear in data

  • Loading branch information...
mariusae committed Mar 10, 2011
1 parent 0e58221 commit 518aa478f373ef8d05d50e56355121c0a10849ea
Showing with 12 additions and 1 deletion.
  1. +6 −1 src/main/antlr/Mustache.g
  2. +6 −0 src/test/scala/org/monkey/mustache/MustacheSpec.scala
@@ -30,6 +30,10 @@ document :
| mustache
)*;
+/**
+ * TODO: figure out how to get ``Data+'' to work here -- this way we
+ * don't do a character-at-a-time.
+ */
body : Data { root.addChild(nodeFactory.newDataNode($Data.text)); };
mustache
@@ -102,4 +106,5 @@ Gt : { inTag }?=> '>' ;
Ws : { inTag }?=> ( '\t' | ' ' | '\r' | '\n'| '\u000C' )+
{ $channel = HIDDEN; };
-Data : { !inTag }?=> (~'{')+ ;
+Data : { !inTag }?=> . ;
+
@@ -8,6 +8,12 @@ object MustacheSpec extends Specification {
def eval(mustache: String, dictionary: Dictionary): String =
(new Mustache(Source.fromString(mustache)))(dictionary)
+ "data" should {
+ "not interpret single '{'s" in {
+ (new Mustache("{"))(Dictionary()) must be_==("{")
+ }
+ }
+
"basic interpolation" should {
val mustache = "hello {{world}}!"
"substitute as expected" in {

0 comments on commit 518aa47

Please sign in to comment.