Menu

#426 VERSION_2_3_22 incompatible improvements break .template_name

2.3.23
closed-fixed
nobody
None
5
2015-07-05
2015-04-21
No

When setting the incompatible improvements to 2.3.22, .template_name stops to working correctly. It will no longer return the correct value.

.template_name is documented to return "The name of the current template (available since FreeMarker 2.3.14).", but it does return Environment.getTemplate().getName(), which is "broken" by incompatible improvements 2.3.22.

.template_name should rater return Environment.getCurrentNamespace().getTemplate().getName().

If future versions of Freemarker can no longer support .template_name it should at least be documented.

Discussion

  • Dániel Dékány

    So, with incompatible_improvements 2.3.22, .template_name always return the name of the main template. Earlier it did some erratic thing, but surely it happened to return the expected name inside an #include-d template. And frankly, a haven't realized that Environment.getTemplate() was exposed through a special variable, because this way it was indeed a too backward incompatible change for a micro version "incomplatible improvement". Sadly, nobody has brought this up during the RC period.

    Using Environment.getCurrentNamespace().getTemplate().getName() won't solve this, because exactly when you #include another template, the current namespace won't change.

    As of the future, it will be possible to return both the main template name and the current template name (this time correctly). Then template_name will have to be deprecated and .main_template_name and .current_template_name will have to be added. I will see how can I fit that in into 2.3.23.

     
  • Dániel Dékány

    • status: open --> open-accepted
    • Group: undecided --> 2.3.23
     
  • Dániel Dékány

    This is now fixed on GitHub 2.3 and 2.3-gae branches. Setting incompatible_improvements to 2.3.23 restores the backward compatible behavior of .template_name. In additionally, there are two new special variables: .current_template_name and .main_template_name. Unlike .template_name, these work with macro calls as expected.

     
  • Dániel Dékány

    • status: open-accepted --> open-fixed
     
  • Dániel Dékány

    • status: open-fixed --> closed-fixed
     

Log in to post a comment.

MongoDB Logo MongoDB