Willow

Default Values

By default, if the data returned to a willow is not in a format that can be rendered, either a string, integer or boolean or an array of strings, integers or booleans and indexed arrays of strings, integers or booleans, the willow is not rendered.
Version 2.1.1
Latest Changes:

* Update: moved all object instatiation to plugin hook - all objects are stored in a global getters and setters and accessed via willow() function.


Documentation about each release is updated as often as possible, but may lag behind the Master Branch or other generated documentation.

Featured Work
Quinta de Sant’Ana, Portugal
Quinta de Sant’Ana, Portugal

Quinta de Sant'Ana overlooks the picturesque village of Gradil with its cobbled streets, white washed houses and hospitable inhabitants.


Overview

However, it is possible to stipulate default data to render, either globally, or on a per-field basis, by passing the default value in template configuration, here is an example:

{~ user~member_connections 
    {+ [array] config->default = all: "<p class='ml-3'>No members here, yet...</p>" +} 
~}

Willow will try to locate and return data from the user->member_connections() class method, if the data returns correctly formatted, the default value is ignored. However, if the data is empty of mal-formed, the default value is used to replace single or all fields – which is determined by the values passed in the configuration array.

Here are 3 possible variants of the passed configuration:

This example below replaces the key “one” in the returned data array – if it exists and is empty – with the default value.

config->default = one: "<p class='ml-3'>No members here, yet...</p>"

This example below replaces the keys “one” and “two” in the returned data array – if they exists and are empty – with the default value.

config->default = one: "<p class='ml-3'>No members here, yet...</p>" & two: "<p class='ml-3'>Oops, sorry</p>"

The final example below replaces all keys in the returned data array – if they exists and are empty – with the default value, this is most useful for loops which return empty data arrays.

config->default = all: "<p class='ml-3'>No members here, yet...</p>"