Nova · Layouts
Nested conditionals
An if inside an if. The outer one asks whether anybody is signed in, the inner one what kind of member they are: three screens from one layout.
{
id: 'nested-conditionals',
data: { member: { name: 'Ada', staff: true } },
layout: {
if: '$.member',
then: {
if: '$.member.staff',
then: {
component: 'Text',
children: '{{$.member.name}} works at the box office.',
},
else: {
component: 'Text',
children: '{{$.member.name}} is a member.',
},
},
else: { component: 'Text', children: 'Nobody is signed in.' },
},
}Ada works at the box office.
Nothing. It is only drawn.
{ member: { name: 'Ada', staff: true } }Ada works at the box office.
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.