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>"