Re: Printing on the stdout within a template

Daniel Dekany <[email protected]>
Newsgroups gmane.comp.web.freemarker.user
Message-ID <[email protected]>
Wednesday, June 24, 2009, 5:48:58 PM, Federica Oltolina wrote:
> Hi all, 
> anyone knows if there is a way to have something similar to
>
> <%System.out.println("'till here it's ok");%>
>
> wihtin a template?
>
> My aim is tracking variables or localizing errors in the code of the template.
> If it's not possible writing on the stdout is there a way to write
> on whatever file (maybe some log file)?

It's completely up to the framework that embeds FreeMarker...
FreeMarker doesn't interfere with this business. So if the embedding
framework doesn't provide a FreeMarker directive for this (something
like <@foo.log "Till here's OK" />), you will have to provide a such
directive yourself: implement TemplateDirectiveModel, and either put
it onto the data-model (even with config.setSharedVariable(...), if
you can access the freemarker.template.Configuration object at its
initialization), or put it into your application-specific
#import/#include file with <#assign log =
"com.example.MyLoggerDirective"?new()>

>
>
> Kindly regards 
> Federica
-- 
Best regards,
 Daniel Dekany


------------------------------------------------------------------------------
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.