Skip to content

Willow Tags

Q edited this page Dec 13, 2020 · 21 revisions

All Willow tags include a matching opening and closing pair, starting and ending with a curly bracket and one other internal character, as follows:


{~ ui~willow ~}

Willows are the most commonly used tag, along with {{ variables }} and are essentially functions, they accept {+ arguments +} and {@ loops @} or [ flags ]

Example:

{~ ui~hello {+ <div>Willow says {{ hello }}</div> +} ~}

This tag call tries to find the ui ( context ) hello ( task ) method ( ui::hello() ) and wrap the return data in simple html:

Return:

<div>Willow says Hello</div>

Read more about Willow Tags


{{ variable }}

Variables are "placeholders" which are replaced by the data returned from the calling method, they are usually placed inside "Willow" tags or blocks, they accept [ flags ]

Example:

{~ ui~hello {+ <div>Willow says {{ [e] hello }}</div> +} ~}

This tag call tries to find the ui ( context ) hello ( task ) method ( ui::hello() ) and apply htmlentities() escaping via the [e] flag to the variable data:

Return:

<div>Willow says Isn&#039;t it a nice day</div>

Read more about Variable Tags


{+ argument +}

Arguments allow for markup and configuration options to be passed from template calls - Read more about Argument Tags


{@ loop @}

Loops are used to iterate over returned data arrays - Read more about Loop Tags


{: scope :}

Scopes define the specific data array key to iterate over, inside Loop Tags - Read more about Scope Tags


{% php_function %}

PHP Functions can be called directly from within Willow templates - Read more about PHP Function Tags


{> partial <}

Partials are re-usable script blocks, which are not parsed before rendering - Read more about Partial Tags


{! comment !}

Comments are handy ways to leave notes to yourself or the developer from within the Willow template - Read more about Comment Tags


The only additional tag available currently is the flag tag, which is composed of an opening and closing square bracket:

[ flag ]

Flags are placed within other Willow tags to control the format and usage of returned data.

Read more about Flag Tags


Clone this wiki locally