Nova · Layouts
Directives
Where a value is wanted, a directive works one out. $eq says whether two values are the same; here it decides an if, so the layout can ask more of the data than whether something is there.
{
id: 'directives',
data: { tab: 'members', seats: 2 },
layout: {
component: 'Stack',
children: [
{
if: { $eq: ['$.tab', 'members'] },
then: { component: 'Text', children: 'Showing members' },
else: { component: 'Text', children: 'Showing everyone' },
},
{
if: { $eq: ['$.seats', 1] },
then: { component: 'Text', children: 'One seat' },
else: { component: 'Text', children: '{{$.seats}} seats' },
},
],
},
}Showing members
2 seats
Nothing. It is only drawn.
{ tab: 'members', seats: 2 }Showing members 2 seats
Left: the action as the package ships it. Right: the same action running in this page, rendered with this site’s components. Below: the action run as the example specifies, on the installed package.