Nesting metadata
A walk-through on creating nested metadata structures
Object blocks
// A simple example (no grandchildren)
{
string: 'Top-level parent',
children: ['A child with no child of its own', 'Another childless child']
}
// or :
{
string: 'Grandparent',
children: [
{string: 'Parent',
children: ['One grandchild', 'Two grandchildren']
}
]
}
// The simplest way to create such blocks is to do the following :
// 1) Create an Object block, with an empty 'children' Array.
let parentBlock = {string: "Text of the parent", children: []};
// 2) Push elements to add them to the 'children' Array.
// They can be strings :
children.push('A childless child');
// Or they can be Object blocks :
children.push({string: 'A child with a child of its own'}, children: ['The grandchild']);
Processing order for nested blocks
Creating formatting functions for nested output
Examples of output
Last updated