Created
May 12, 2019 16:05
-
-
Save localhostdotdev/ba7b38b1b4a1c6ba6c799ee3c63c1fa6 to your computer and use it in GitHub Desktop.
Revisions
-
localhostdotdev created this gist
May 12, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,34 @@ { 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