Accessing Model Hierarchy Recursively
When working with a nested model, you may want to access and printout the details of elements within a hierarchy recursively. Since the level of model can be unlimited, it is hard to write a custom element template with a chunk of code repeated a certain number of time, not to mention this way of coding will make the template messy and hard to maintain. To solve this problem you can form a recursive template call by applying the concept of template referencing. If you are a programmer, the idea is exactly the same as a recursive method call in programming. All you need to do is to add the element in the appropriate place in the template, to instruct the template engine to process the same template, forming a self-loop. We will walk you through the details in this article.