C# Class NVelocity.Template

This class is used for controlling all template operations. This class uses a parser created by JavaCC to create an AST that is subsequently traversed by a Visitor. Template template = Velocity.getTemplate("test.wm"); IContext context = new VelocityContext(); context.Put("foo", "bar"); context.Put("customer", new Customer()); template.Merge(context, writer);
Inheritance: NVelocity.Runtime.Resource.Resource
Datei anzeigen Open project: rasmus-toftdahl-olesen/NVelocity Class Usage Examples

Public Methods

Method Description
InitDocument ( ) : void

initializes the document. init() is not longer dependant upon context, but we need to let the init() carry the template name down through for VM namespace features

Merge ( IContext context, TextWriter writer ) : void

The AST node structure is merged with the context to produce the final output. Throws IOException if failure is due to a file related issue, and Exception otherwise

Process ( ) : bool

Gets the named resource as a stream, parses and inits.

Protected Methods

Method Description
ObtainStream ( ) : Stream

Method Details

InitDocument() public method

initializes the document. init() is not longer dependant upon context, but we need to let the init() carry the template name down through for VM namespace features
public InitDocument ( ) : void
return void

Merge() public method

The AST node structure is merged with the context to produce the final output. Throws IOException if failure is due to a file related issue, and Exception otherwise
/// if template not found from any available source. /// /// if template cannot be parsed due to syntax (or other) error. /// /// anything else. ///
public Merge ( IContext context, TextWriter writer ) : void
context IContext Context with data elements accessed by template
writer System.IO.TextWriter writer for rendered template
return void

ObtainStream() protected method

protected ObtainStream ( ) : Stream
return Stream

Process() public method

Gets the named resource as a stream, parses and inits.
/// if template not found from any available source. /// /// if template cannot be parsed due to syntax (or other) error. /// /// some other problem, should only be from initialization of the template AST. ///
public Process ( ) : bool
return bool