10.10.3 JSON View Templates
You can define templates starting with underscore _. For example given the following template called _person.gson:
model {Person person}json {name person.nameage person.age}
You can render it with a view as follows:
model {Family family}json {name family.father.nameage family.father.ageoldestChild g.render(template:"person", model:[person: family.children.max { Person p -> p.age } ])children g.render(template:"person", collection: family.children, var:'person')}
Alternatively for a more concise way to invoke templates, using the tmpl variable:
model {Family family}json {name family.father.nameage family.father.ageoldestChild tmpl.person( family.children.max { Person p -> p.age } ] )children tmpl.person( family.children )}