freemarker-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Daniel Dekany (JIRA)" <>
Subject [jira] [Commented] (FREEMARKER-74) Constructors freemarker.template.Template
Date Tue, 26 Sep 2017 11:31:00 GMT


Daniel Dekany commented on FREEMARKER-74:

Using the default {{Configuration}} is highly discouraged (and by passing in {{null}} you
are use that). That's something from the dark ages, and is supported for backward compatibility
only. That's why there won't be a constructor overload without {{Configuration}} parameter.
So I would recommend creating a {{Configuration}} singleton and pass it in as the last parameter.
(And really, there's lot to configure, as the defaults are not very good, they are just backward
compatible... see Also
setting a default auto-escaping is maybe important in your case, as your template names don't
end with ".ftlh" or ".ftlx".)

The template name parameter can be {{null}}, and that's certainly better than {{"dontCare"}},
because then FreeMarker will understand that there's simply no name.

Also, certainly this is just a simplified example, but just in case, the exception (with the
cause chain) should be passed to {{raiseError}} somehow, or else you will not see why the
FreeMarker template has failed (it usually gives quite helpful error messages).

> Constructors freemarker.template.Template
> -----------------------------------------
>                 Key: FREEMARKER-74
>                 URL:
>             Project: Apache Freemarker
>          Issue Type: Improvement
>            Reporter: Jörg Rade
> # add java doc to all Constructors 
> # change 'String name' to 'String templateDescription'
> # provide a Constructor where the 'templateSourceString' can be passed in directly
> ad 3) I have a use case where I have already have the template source at hand and all
the file io is handled elsewhere - so I may even get along without cfg (insofar as it deals
with file io)

This message was sent by Atlassian JIRA

View raw message