API / Apache Velocity Interview questions
What is the purpose of the #parse directive?
#parse loads another template file and processes it as VTL, evaluating any directives and references it contains, then splices the resulting output into the calling template at that point.
#parse("header.vm")
<div class="content">$body</div>
#parse("footer.vm")
Because the parsed file can itself contain #parse calls, Velocity enforces a configurable maximum recursion depth (the parse_directive.maxdepth property, default 20) to prevent infinite recursive parsing. This makes #parse the right tool for shared, dynamic fragments like headers, footers, or navigation menus that need access to the same context as the calling template.
More Related questions...