[
https://issues.apache.org/jira/browse/FREEMARKER-74?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16180623#comment-16180623
]
Daniel Dekany edited comment on FREEMARKER-74 at 9/26/17 12:18 PM:
-------------------------------------------------------------------
Using the default {{Configuration}} is highly discouraged (and by passing in
{{null}} you are using 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
http://freemarker.org/docs/pgui_quickstart_createconfiguration.html. 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 template has failed (it usually gives quite
helpful error messages).
Can you tell where exactly did you miss the JavaDoc?
was (Author: ddekany):
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
http://freemarker.org/docs/pgui_quickstart_createconfiguration.html. 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: https://issues.apache.org/jira/browse/FREEMARKER-74
> 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
(v6.4.14#64029)