Discussion:
[FreeMarker-user] adding a new template to an existing FreeMarker system
spornitz
2016-06-08 19:26:53 UTC
Permalink
Hi;

We are using a vendor's system that uses FreeMarker. We would like to add a
couple templates to their existing system; they can't seem to tell us what
we would have to change to have the templating engine pick them up, however.

Generally: what do you have to change in a FreeMarker-based application to
have the template engine pick up brand new templates?

thanks for any clues...



--
View this message in context: http://freemarker.624813.n4.nabble.com/adding-a-new-template-to-an-existing-FreeMarker-system-tp4655634.html
Sent from the freemarker-user mailing list archive at Nabble.com.
Daniel Dekany
2016-06-08 22:48:49 UTC
Permalink
Hi,

FreeMarker is very configurable on this regard, an it doesn't even
have a default location for templates, so everyone has to configure it
to something explicitly. But you can try a few things:

- See if there's something like templateLoader or template_loader or
maybe templatePath or templatePaths around. This is what specifies
from where the templates are loaded from. But maybe they do it from
compiled Java code, in which case you can't easily modify it.

- Find the existing templates (usually files with "ftl" file
extension). If they are inside jar-s, then maybe you can just add
your own jar-s which put further templates into the same
subdirectory.

- If they are using a well known framework (like Spring), chances are
that it has its own conventions for configuring FreeMarker, and
knowing that maybe you can refine it.

- Start the JVM in debug mode, and put a breakpoint on
freemarker.cache.TemplateCache.findTemplateSource(String). You will
see a TemplateLoader field referred there. That's the object that's
responsible for actually loading the template files, so from its
concrete class and fields you can extract this information.

And please in the future use ***@freemarker.incubator.apache.org, as
this is list was retired!
Post by spornitz
Hi;
We are using a vendor's system that uses FreeMarker. We would like to add a
couple templates to their existing system; they can't seem to tell us what
we would have to change to have the templating engine pick them up, however.
Generally: what do you have to change in a FreeMarker-based application to
have the template engine pick up brand new templates?
thanks for any clues...
--
Thanks,
Daniel Dekany
s***@mymts.net
2016-06-09 15:14:51 UTC
Permalink
Thanks very much! Maybe when I figure this out, I'll inform the vendor so they can tell their customers LOL.

-Bill

----- Original Message -----
From: "Daniel Dekany" <***@freemail.hu>
To: "spornitz" <***@mts.net>
Cc: freemarker-***@lists.sourceforge.net
Sent: Wednesday, June 8, 2016 5:48:49 PM
Subject: Re: [FreeMarker-user] adding a new template to an existing FreeMarker system

Hi,

FreeMarker is very configurable on this regard, an it doesn't even
have a default location for templates, so everyone has to configure it
to something explicitly. But you can try a few things:

- See if there's something like templateLoader or template_loader or
maybe templatePath or templatePaths around. This is what specifies
from where the templates are loaded from. But maybe they do it from
compiled Java code, in which case you can't easily modify it.

- Find the existing templates (usually files with "ftl" file
extension). If they are inside jar-s, then maybe you can just add
your own jar-s which put further templates into the same
subdirectory.

- If they are using a well known framework (like Spring), chances are
that it has its own conventions for configuring FreeMarker, and
knowing that maybe you can refine it.

- Start the JVM in debug mode, and put a breakpoint on
freemarker.cache.TemplateCache.findTemplateSource(String). You will
see a TemplateLoader field referred there. That's the object that's
responsible for actually loading the template files, so from its
concrete class and fields you can extract this information.

And please in the future use ***@freemarker.incubator.apache.org, as
this is list was retired!
Post by spornitz
Hi;
We are using a vendor's system that uses FreeMarker. We would like to add a
couple templates to their existing system; they can't seem to tell us what
we would have to change to have the templating engine pick them up, however.
Generally: what do you have to change in a FreeMarker-based application to
have the template engine pick up brand new templates?
thanks for any clues...
--
Thanks,
Daniel Dekany
Loading...