freemarker-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Daniel Dekany (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (FREEMARKER-84) Improve include directive to detect whether template exists
Date Sat, 03 Mar 2018 16:29:00 GMT

    [ https://issues.apache.org/jira/browse/FREEMARKER-84?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16384721#comment-16384721
] 

Daniel Dekany commented on FREEMARKER-84:
-----------------------------------------

Well, it has much less boilerplate in FM3. Surely there the "options" argument doesn't exist,
but if you only look at the part where the template name argument is get, and how the include
and import methods are treated...

> Improve include directive to detect whether template exists
> -----------------------------------------------------------
>
>                 Key: FREEMARKER-84
>                 URL: https://issues.apache.org/jira/browse/FREEMARKER-84
>             Project: Apache Freemarker
>          Issue Type: Improvement
>          Components: engine
>    Affects Versions: 2.3.27-incubating
>            Reporter: Yanming Zhou
>            Priority: Major
>             Fix For: 2.3.28-incubating
>
>
> I requested feature `ignore_missing=true` of <#include> and freemarker have implemented
it, but it cannot handle fallback like
> {code}
> <#assign path="relative.ftl">
> <#if isTemplatePresent(path)>
> <#include path>
> <#else>
> template "${path}" is not exists
> </#if>
> {code}
> Proposal 1:
> Introduce a new special variable like "template_included" similar to "$?" of shell exit
code
> {code}
> <#include path ignore_missing=true>
> <#if !.template_included>
> template "${path}" is not exists
> </#if>
> {code}
> Proposal 2:
> Add an argument like "template_included" for include directive
> {code}
> <#include path ignore_missing=true template_included="pathExists">
> <#if !pathExists>
> template "${path}" is not exists
> </#if>
> {code}
> Proposal 3:
> Introduce a new special directive such as <#missing> similar to html <noscript>
tag
> {code}
> <#include path>
> <#missing>
> template "${path}" is not exists
> </#missing>
> </#include>
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message