Reference: Conditional Statements | Elements Manual
I note that @if statement can only check a property for being true or false (!property for which there is no example). I think this page would benefit with having a reference section stating expliciitly what is allowed.
The documentation states "When performing complex logic like string comparisons, use the hooks file to perform this logic and provide simple bool values to the template.”.
At the moment the docs don’t have an example of how to do this, AFAICS.
I want to be able to select from a list:
{
"title": "Debug",
"properties": [{
"title": "Show",
"id": "debugVisibility",
"select": {
"default": "none",
"items": [{
"value": "none",
"title": "None"
}, {
"value": "edit",
"title": "Edit"
}, {
"value": "preview",
"title": "Preview"
}, {
"value": "both",
"title": "Edit & Preview"
}]
}
},
Then in hooks.js, set a new property to true for example if I am in preview and the debugVisibility is set to preview or both.
I am not clear how I would use hooks.js to do this, i.e. retrieve the value of debugVisibility and set a new property to true or false that can be @if’d in the template to decide whether to output some html or not.