UIZE JavaScript Framework

JAVASCRIPT EXAMPLES Structured Record Population

In this example, an instance of the Uize.Widget.Population class is being used to populate a node with HTML by combining a template string with a record set. The records are not made up merely of simple values, but each field is itself an object containing further fields. These "deep" fields can be substituted into the template string just as easily as top level fields would. In this example, the template item for the Uize.Widget.Population instance is being generated by applying the Uize.Widget.Population.makeTemplateItem static method on the first record of the set. Using {KEY} as the token naming syntax ensures that the values of the deep fields can be substituted into the template string with tokens such as {address.street}, which would substitute the value of the street field of the address field (represented by the key address.street). Best to look at the source code of the example to get the gist of it.

{name.first} {name.last}
street
{address.street}
city
{address.city}
state
{address.state}
zip
{address.zip}
cell {phone.cell} home {phone.home} fax {phone.fax}