hxl icon indicating copy to clipboard operation
hxl copied to clipboard

impl Template sub language

Open drowzy opened this issue 4 years ago • 0 comments

Reference:

Within quoted and heredoc string expressions, the sequences ${ and %{ begin template sequences. Templates let you > directly embed expressions into a string literal, to dynamically construct strings from other values.

Template = (
    TemplateLiteral |
    TemplateInterpolation |
    TemplateDirective
)*
TemplateDirective = TemplateIf | TemplateFor;
TemplateInterpolation = ("${" | "${~") Expression ("}" | "~}";

TemplateIf = (
    ("%{" | "%{~") "if" Expression ("}" | "~}")
    Template
    (
        ("%{" | "%{~") "else" ("}" | "~}")
        Template
    )?
    ("%{" | "%{~") "endif" ("}" | "~}")
);

TemplateFor = (
    ("%{" | "%{~") "for" Identifier ("," Identifier) "in" Expression ("}" | "~}")
    Template
    ("%{" | "%{~") "endfor" ("}" | "~}")
);

drowzy avatar Sep 24 '21 13:09 drowzy