Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
{ function j(string) { return string.join('') } }
template =
(
interpolation /
tag /
$(!interpolation !tag .)
)+
ws = (" " / "\n")*
value = [^ ]
// {{ this }}
open_interpolation = "{{"
close_interpolation = "}}"
not_close_interpolation =
ws !close_interpolation m:value ws { return m }
interpolation =
open_interpolation m:not_close_interpolation+ close_interpolation { return j(m) }
// {% this %}
open_tag = "{%"
close_tag = "%}"
not_close_tag =
ws !close_tag m:value ws { return m }
tag_start = !tag_end open_tag m:not_close_tag+ close_tag { return j(m) }
tag_end = open_tag ws "end" not_close_tag+ close_tag
tag = tag_start template tag_end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment