Syntax Pragmas - thegrandpoobah/mustache.js GitHub Wiki
Mustache Syntax: Pragmas
Description
Pragma tags in Mustache change the behaviour of the Mustache interpreter itself. Pragmas are useful for obtaining non-spec-complaint behaviour or to enable features that would otherwise be disabled by default. Pragma tags are opened with the {{% token and closed with the }} token. The contents of the Pragma tag is split into two components. The first is the name of the pragma and is mandatory. Similar to other tag names, whitespace can only be present as prefix and postfix, but not in the middle. Other characters are okay. The second component is the pragma options and is a comma seperated list of key-value pairs (i.e. key=value,key=value,key=value). Each valid pragma type has its own list of valid options. Look at the documentation for each pragma for more information.
Pragmas are pre-processed during the parsing phase of each template file and will only be parsed once. Their placement in the input file has no bearing on their functionality. Pragmas have file scope and are not inherited, meaning that each partial must define its own pragmas.
Syntax Example
Fictional pragma with no options:
{{%BUGS-BUNNY-PARSER}}
Fictional pragma with two options:
{{%WILE-E-COYOTE useAcme=true,retries=1}}
Example of partial scope:
{{!Entry Point Template!}}
{{%DAFFY-DUCK-PARSER}}
{{>a_partial}}
{{!a_partial template!}}
{{! Will not have the DAFFY-DUCK-PARSER prag!}}
Implemented Pragams
Spec Compliance
Pragmas are not defined in the Mustache specification. They are used in various different implementations of the spec for various different purposes.