Uploaded image for project: 'Apache Freemarker'
  1. Apache Freemarker
  2. FREEMARKER-83

Introduce new special variable "outer_template_name" beside "main_template_name"

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Implemented
    • Affects Version/s: 2.3.27-incubating
    • Fix Version/s: 2.3.28
    • Component/s: engine
    • Labels:
      None

      Description

      for example, a.ftl include b.ftl, b.ftl include c.ftl

        current_template_name outer_template_name main_template_name
      a.ftl a.ftl null a.ftl
      b.ftl b.ftl a.ftl a.ftl
      c.ftl c.ftl b.ftl a.ftl

      I need such feature to resolve relative path like <#include> directive.
      BTW:
      .current_template_name is lazy evaluation, is this designed or bug

      b.ftl
      <#function templateName value>
      <#return value/>
      </#function>
      
      a.ftl
      <#include "b.ftl">
      ${templateName(.current_template_name)}
      

      it will print "b.ftl" not "a.ftl", workaround:

      a.ftl
      <#include "b.ftl">
      <#assign current_template_name=.current_template_name>
      ${templateName(current_template_name)}
      

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              quaff Yanming Zhou
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: