Skip to content

Commit 565498c

Browse files
authored
Merge pull request #19 from raphaelss/master
Add / as valid character for identifiers.
2 parents 116a3f2 + 130b5b2 commit 565498c

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

lib/mustache_lexer.mll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
}
2727

2828
let space = [' ' '\t' '\n']*
29-
let id = ['a'-'z' 'A'-'Z' '_'] ['a'-'z' 'A'-'Z' '0'-'9' '_']+
29+
let id = ['a'-'z' 'A'-'Z' '_' '/'] ['a'-'z' 'A'-'Z' '0'-'9' '_' '/']+
3030

3131
rule ident = parse
3232
| space '.' space { "." }

lib_test/test_mustache.ml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,29 @@ let tests = [
6464
<b>bar</b>\
6565
<b>bar</b>" ) ] ) ;
6666

67+
("Hello {{ /foo }}!"
68+
, concat [ raw "Hello " ;
69+
escaped "/foo" ;
70+
raw "!" ]
71+
, [ (`O [ "/foo", `String "World" ], "Hello World!") ] ) ;
72+
73+
("{{& deep/path/string }}"
74+
, unescaped "deep/path/string"
75+
, [ (`O [ "deep/path/string", `String "<p>Test content</p>" ],
76+
"<p>Test content</p>") ] ) ;
77+
78+
( "{{#things/with/slashes}}{{v/1/}}-{{v/2/}}{{/things/with/slashes}}"
79+
, section "things/with/slashes" (concat [ escaped "v/1/"
80+
; raw "-"
81+
; escaped "v/2/" ])
82+
, [ ( `O [ "things/with/slashes" ,
83+
`A [ `O [ ("v/1/", `String "1" ) ;
84+
("v/2/", `String "one" ) ] ;
85+
`O [ ("v/1/", `String "2" ) ;
86+
("v/2/", `String "two" ) ] ;
87+
] ],
88+
"1-one2-two" ) ] ) ;
89+
6790
]
6891

6992
let () =

0 commit comments

Comments
 (0)