Skip to content

Latest commit

 

History

History
22 lines (17 loc) · 1.57 KB

sub_templates.tour.md

File metadata and controls

22 lines (17 loc) · 1.57 KB

sub_templates_children

sub-template

A sub-template is needed when the data is from a different data model or when is needed to repeat a sub-template for a vector of data. The syntax is like <!--template_all_summaries start-->. It ends with <!--template_all_summaries end-->

extract sub-template

Only one level deep, only the children. Then recursively the chldren will extract their children. Save them in a vector. The [0] member is the parent template. It is drained from the sub-templates. Only a placeholder remains.

template placeholder

When the template placeholder is found, the method render_sub_template is called. The result is added to the parent node.

render the sub-template

Find it in the sub_templates vector. If the data is a vector, then render_template for every element. Push all nodes to parent node (extend_from_slice).

render

The render method is the same for templates and sub-templates.