Tell me a bit more about this. What exactly is the use-case for this, why do you need this? Why would you just do nothing if that file is missing? If the file is known to be optional, certainly its surrounding also have to be different if it's missing. So it sounds more like there should be a way to *check* if a template is missing (<#if "/maynotexists.ftl"?template_exists >...<#else>...</#if> or like), so then you can chose a different route.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have created a web framework,I am using sitemesh and freemarker as decorator page,In my decorator page,I have preserve some placeholder let application to override or implement.
for example:
assets.ftl top.ftl and bottom.ftl may not exists in some projects,if have no ignoreNotFound,it will throws Exception.
this feature somehow like spring SPEL for placeholder, ${database.password:},if database.password doesn't exists in properties file,append a colon to make it safe.
I have considered <#attempt>attempt block<#recover>recover block</#attempt>,it works fine but throws Exception in console every time.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Clearly something will have to be done to support optional includes, but just silently skipping the inclusion will not be enough for many. Anyway, certainly there won't be much non-bugfix development until the summer. Until that, note that a custom directive (just implement TemplateDirectiveModel) can do this, as the Environment API has getTemplateForInclusion and such.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Tell me a bit more about this. What exactly is the use-case for this, why do you need this? Why would you just do nothing if that file is missing? If the file is known to be optional, certainly its surrounding also have to be different if it's missing. So it sounds more like there should be a way to *check* if a template is missing (<#if "/maynotexists.ftl"?template_exists >...<#else>...</#if> or like), so then you can chose a different route.
View and moderate all "feature-requests Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Feature Requests"
I have created a web framework,I am using sitemesh and freemarker as decorator page,In my decorator page,I have preserve some placeholder let application to override or implement.
for example:
<html>
<head>
<title>${title}</title>
<meta charset="utf-8">
<#include "include/assets.ftl"/>
${head}
</head>
<body>
<#include "include/top.ftl"/>
${body}
<#include "include/bottom.ftl"/>
</body>
</html>
assets.ftl top.ftl and bottom.ftl may not exists in some projects,if have no ignoreNotFound,it will throws Exception.
this feature somehow like spring SPEL for placeholder, ${database.password:},if database.password doesn't exists in properties file,append a colon to make it safe.
I have considered <#attempt>attempt block<#recover>recover block</#attempt>,it works fine but throws Exception in console every time.
Clearly something will have to be done to support optional includes, but just silently skipping the inclusion will not be enough for many. Anyway, certainly there won't be much non-bugfix development until the summer. Until that, note that a custom directive (just implement TemplateDirectiveModel) can do this, as the Environment API has getTemplateForInclusion and such.
Hi,is there any updates?
Nope... I mean, it's question of time, but time is exactly what developers don't have...
Last edit: Dániel Dékány 2013-11-25
Hi, please consider this feature, It's very important for me.
Starting from 2.3.21 it has
ignore_missing=boolean. (There's no way to specify a fall back yet... but that wasn't part of this RFE.)