freemarker-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <>
Subject Re: Proposal for FREEMARKER-84: More flexible handlig of missing templates
Date Sun, 11 Feb 2018 23:52:26 GMT

It seems reasonable. As you suggested, it also seems a little advanced in 
style for most cases.
It's very flexible, a bit verbose for common use, a bit of a learning curve 
for template author.

I would prefer a shorter name, like ".get_template". Isn't it up to the 
template author to decide if the template is optional and what to do if it's
not found? It seems that, from an author's perspective, all we're doing here
is deciding whether to throw an exception when the template is not found (or
include nothing if ignore_missing is set) or to let the author handle the 
situation his own way.

For me it might eliminate the need to provide Java support for default 
templates, something that is on my list to build. So it's a useful addition,
if not super pretty.

Other thoughts...

The first thing that came to mind to ask whether it's practical to also use 
existing freemarker idiom. <#list> has similar use scenarios related to 
present, missing, alternate output.

Sketchy conceptual example...

<#include path,options>
  Stuff you want to output only if include is successful.
  Maybe more stuff to output for successful includes. 
  Stuff you want to do if include failed, for whatever reason.

I guess a problem with this is that <#include> is currently expected to be a
self closing element with no content, and since ftl does not appear to use 
or require self closing elements like <#include/> it would be a pain to 
interpret whether <#include> has content or not. Forcing it to have content 
or include a closing tag would be a big breaking change. Is that the 
reasoning you would apply to this question?

Is Freemarker's approach to self-closing elements like <#include> likely to 
change in Freemarker 3? I didn't see anything about that in a quick review 
of the web page on FM3. Maybe you don't even think of these directives as 
elements. For a user familiar with HTML or XML it's hard to think of them 

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message