Skip to content

Commit

Permalink
Merge pull request #19 from raphaelss/master
Browse files Browse the repository at this point in the history
Add / as valid character for identifiers.
  • Loading branch information
rgrinberg authored Jul 31, 2016
2 parents 116a3f2 + 130b5b2 commit 565498c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/mustache_lexer.mll
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
}

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

rule ident = parse
| space '.' space { "." }
Expand Down
23 changes: 23 additions & 0 deletions lib_test/test_mustache.ml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,29 @@ let tests = [
<b>bar</b>\
<b>bar</b>" ) ] ) ;

("Hello {{ /foo }}!"
, concat [ raw "Hello " ;
escaped "/foo" ;
raw "!" ]
, [ (`O [ "/foo", `String "World" ], "Hello World!") ] ) ;

("{{& deep/path/string }}"
, unescaped "deep/path/string"
, [ (`O [ "deep/path/string", `String "<p>Test content</p>" ],
"<p>Test content</p>") ] ) ;

( "{{#things/with/slashes}}{{v/1/}}-{{v/2/}}{{/things/with/slashes}}"
, section "things/with/slashes" (concat [ escaped "v/1/"
; raw "-"
; escaped "v/2/" ])
, [ ( `O [ "things/with/slashes" ,
`A [ `O [ ("v/1/", `String "1" ) ;
("v/2/", `String "one" ) ] ;
`O [ ("v/1/", `String "2" ) ;
("v/2/", `String "two" ) ] ;
] ],
"1-one2-two" ) ] ) ;

]

let () =
Expand Down

0 comments on commit 565498c

Please sign in to comment.