Re: extend the Include or Environment classes

Daniel Dekany <[email protected]>
Newsgroups gmane.comp.web.freemarker.devel
Message-ID <[email protected]>
Tuesday, June 28, 2011, 2:30:12 PM, Francis Mendoza wrote:

> Hi Denis,
>
>    Thanks for your quick reply. I've had a time to play around with
> the directive at the moment and I seem to get your point. I'm just
> testing stuff out of the example Freemarker gave as per your given link.
>
>   Im almost there but I have a question, how can I achieve this:
>
> <@test y="test2.ftl">
>   
>   <#include y>
> </@repeat>
>
> and my class "Test" implements TemplateDirectiveModel? How can I
> get the y to be rendered inside the @test?

I suspects there are some misunderstanding regarding how directives
supposed to work. Why @test is closed with @repeat? Why would y be
visible for the #include when it was just a parameter to @test?
Anyway, if you just wanted something like #include but with a somewhat
different behavior, certainly you should just implement a directive
that does that directly. Something like:

  <@myFramework.include "test2.ftl" />

and then in the implementation of "include" you can use the
Environment API to try to include templates, etc.

Or, as Attila said, maybe a MultiTemplateLoader is the good solution.

> This may seem like a
> stupid question but im a little dizzy. I know im almost there....
>
>
>
>
> On Tue, Jun 28, 2011 at 3:55 PM, Denis Bredelet <[email protected]> wrote:
> Hi Francis
>
>
> Hi All,
>
>    I'm working right now on shifting our templating engine from
> StringTemplate to Freemarker. One of the requirement
> was that if the .ftl file (an #include) cannot be found, it will
> look for it at the common directory. I've look at the API and 
> Freemarker codes but there seem to be no way for me to do this on the "includes".
>
> If the built-in #include does not work for you, you should be able
> to implement it with your own directive:
>
> http://freemarker.org/docs/pgui_datamodel_directive.html
>
> -- Denis. 
>
>
>    I checked on the Environment.java and saw the rendering of the
> includes down there: getTemplateForInclusion. Its
> a public method alright but then the class is marked final so I
> can't extend it to solve my problem. Is there a possibility
> for this class to be marked as not final on the future releases? 
>    
> -- 
> Francis Mendoza
>
>
> JET Team
> Flight Centre Technology
> Level 4, 545 Queen Street, BRISBANE, QLD 4000.
> Phone:  04231 53500
> email:  [email protected]
>
> ------------------------------------------------------------------------------
> All of the data generated in your IT infrastructure is seriously valuable.
> Why? It contains a definitive record of application performance, security
> threats, fraudulent activity, and more. Splunk takes this data and makes
> sense of it. IT sense. And common sense.
> http://p.sf.net/sfu/splunk-d2d-c2
> _______________________________________________
> FreeMarker-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/freemarker-devel
>
> ------------------------------------------------------------------------------
> All of the data generated in your IT infrastructure is seriously valuable.
> Why? It contains a definitive record of application performance, security
> threats, fraudulent activity, and more. Splunk takes this data and makes
> sense of it. IT sense. And common sense.
> http://p.sf.net/sfu/splunk-d2d-c2
> _______________________________________________
> FreeMarker-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/freemarker-devel
>
>
>
>

-- 
Best regards,
 Daniel Dekany


------------------------------------------------------------------------------
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security 
threats, fraudulent activity, and more. Splunk takes this data and makes 
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2d-c2
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.