TemplateSyntaxParser |
template = (variableExpression | expression | condition | loop | include | text)*
variableExpression = "{", variable, "}"
expression = "${", expressionContent, "}"
condition = "# IF ", "NOT "?, expression, "#", template, ("# ELSE #, template)?, "# ENDIF #"
loop = "# START ", expression, " #", template, "# END (?:name)? #"
include = "# INCLUDE ", name, " #"
text = .+
expressionContent = array | function | variable | constant
function = "(\w+::)?\w+(", parameters, ")"
parameters = expressionContent | (expressionContent, (",", expressionContent)+)
variable = simpleVar | loopVar
constant = "'.+'" | [0-9]+ | array
array = "array(", arrayContent, ")"
arrayContent = arrayElement | (arrayElement, (",", arrayElement)+)
arrayElement = expressionContent | ("'\w+'\s=>\s", expressionContent)
simpleVar = "\w+"
loopVar = "(\w+.)+\w+" |