freemarker.template.utility

Class CaptureOutput

Implemented Interfaces:
TemplateModel, TemplateTransformModel

public class CaptureOutput
extends java.lang.Object
implements TemplateTransformModel

A transform that captures the output of a block of FTL code and stores that in a variable.

As this transform is initially present in the shared variable set, you can always access it from the templates:

 <@capture_output var="captured">
   ...
 </@capture_output>
 

And later in the template you can use the captured output: ${captured}

This transform requires one of three parameters: var, local, or global. Each of them specifies the name of the variable that stores the captured output, but the first creates a variable in a name-space (as <#assign>), the second creates a macro-local variable (as <#local>), and the last creates a global variable (as <#global>).

In the case of an assignment within a namespace, there is an optional parameter namespace that indicates in which namespace to do the assignment. if this is omitted, the current namespace is used, and this will be, by far, the most common usage pattern.

Version:
$Id: CaptureOutput.java,v 1.31 2004/01/06 17:06:43 szegedia Exp $

Fields inherited from interface freemarker.template.TemplateModel

NOTHING

Method Summary

Writer
getWriter(Writer out, Map args)

Method Details

getWriter

public Writer getWriter(Writer out,
                        Map args)
            throws TemplateModelException
Specified by:
getWriter in interface TemplateTransformModel