Re: Template Subprocessing

Daniel Dekany <[email protected]>
Newsgroups gmane.comp.web.freemarker.user
Message-ID <[email protected]>
Normally the output of the included templates go directly into the
output "stream" indeed, because that's the efficient way of doing
this. But you can capture the output of any part of a template into a
string variable with <#assign myVar>...template fragment...</#assign>
(and similarly with #local and #global). You can also transform the
output to Base64 encoded on-the-fly (i.e. without buffering much) with
a custom directive (see TemplateDirectiveModel), since a directive can
replace the output Writer inside its nested content, and so that
custom Writer can be a filter that eventually writes into the Writer
that it replaced.


Monday, May 24, 2010, 7:33:12 PM, Morgan Conner wrote:

> So we have a small configuration for leveraging FreeMarker to produce the XML
> payload of SOAP messages.  Works great.  Now we're trying to call a service that
> wants to have part of the document base64 encoded.  The encoded content is also
> XML that needs to be created using data from the model.
>
> Unfortunately, I cannot change the service to make it less dysfunctional, so the
> encoding is required.  I'm also somewhat constrained as to how FreeMarker is
> invoked, so I can't process it all in code.
>
> Maybe I'm dreaming, but:
> Has anyone seen anything like this before?
> Is there anyway to build all this into one template?  
> Is there an easy way to get the results of processing a sub-template into a
> string in the primary template (which I could then call out to Java to get
> base64 encoded)?
>
> My last questions seems like a straightforward way to do it, but most of the
> code I've looked at returns the included/parsed files in the output and not in a
> string.  Am I missing something?
>
>
> ------------------------------------------------------------------------------
>
> _______________________________________________
> FreeMarker-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/freemarker-user
>

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