Re: Is there any way to include from outside the template root directory?

Daniel Dekany <[email protected]>
Newsgroups gmane.comp.web.freemarker.user
Message-ID <[email protected]>
Friday, January 28, 2011, 1:52:41 AM, Johann Petrak wrote:

> I am using FreeMarker with FMPP to generate files from the command line
> from XML source files. To do that, I have created a lot of macros that
> simplify accessing the information in that kind of XML files.
>
> This should work with a number of different templates, each in their own
> template dir to generate different kinds of output files. But for all of
> them I would need the same set of macros! So ideally, the macros would
> be *outside* each of the template directories and shared by them -- but
> this seems to be impossible because <#include> always stays inside the
> template directory.
>
> Is there any way, any trick tom make <#include "../../somefile.ftl">
> work when that relative path points outside the template directory? This
> would be great in cases where the user actually knows what he is doing.
>
> Any help would be greatly appreciated -- this would immensely simplify
> the maintenance of the files that contain all those macros that I
> need to share between the different template directories.

While FreeMarker requires you to remain inside the template root
directory, it doesn't assume that it's a "real" directory. It's just a
primitive virtual file-system. Utilizing that, FMPP has this feature:

  FreeMarker links (external includes)
  http://fmpp.sourceforge.net/settings.html#sect29

which was introduced exactly for what you need.

-- 
Best regards,
 Daniel Dekany


------------------------------------------------------------------------------
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.