mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-20 00:23:58 +01:00
29 lines
772 B
Plaintext
29 lines
772 B
Plaintext
// Very crude grammar for a subset of Twig templating syntax
|
|
|
|
@top Template { (directive | Text)* }
|
|
|
|
directive {
|
|
// Insert |
|
|
// Conditional { ConditionalOpen (directive | Text)* ConditionalClose }
|
|
Insert
|
|
}
|
|
|
|
@skip {space} {
|
|
Insert { "{{" DirectiveContent "}}" }
|
|
// ConditionalOpen { "{%" kw<"if"> DirectiveContent "%}" }
|
|
// ConditionalClose { "{%" kw<"endif"> "%}" }
|
|
}
|
|
|
|
kw<word> { @specialize[@name={word}]<Identifier, word> }
|
|
|
|
@tokens {
|
|
Identifier { @asciiLetter+ }
|
|
Text { ![{] Text? | "{" (@eof | ![%{] Text?) }
|
|
space { @whitespace+ }
|
|
DirectiveContent { ![%}] DirectiveContent? | $[%}] (@eof | ![}] DirectiveContent?) }
|
|
@precedence { space DirectiveContent }
|
|
"{{" "}}" // "{%" "%}"
|
|
}
|
|
|
|
@external propSource twigHighlight from "./twig-highlight.ts"
|