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-->
step 1 of 5 View code in GitHub
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.
step 2 of 5 View code in GitHub
When the template placeholder is found, the method render_sub_template is called. The result is added to the parent node.
step 3 of 5 View code in GitHub
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).
step 4 of 5 View code in GitHub
The render method is the same for templates and sub-templates.