C# Класс 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);
Наследование: NVelocity.Runtime.Resource.Resource
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
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.

Защищенные методы

Метод Описание
ObtainStream ( ) : Stream

Описание методов

InitDocument() публичный Метод

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
Результат void

Merge() публичный Метод

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
Результат void

ObtainStream() защищенный Метод

protected ObtainStream ( ) : Stream
Результат Stream

Process() публичный Метод

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
Результат bool