Class

R2Doc::TemplateManager

Inheritance
< Object

The TemplateManager class handles loading and parsing of templates. The actual details of reading the file and creating a parsed template object is handled by a template engine class. TemplateManager‘s responsibilities are to record registration of template directories and engines, to locate the correct template source file, and then dispatch to the right engine.

A template engine class need only supply a very limited interface. It must supply a class method named load which accepts a file name as a single argument. The load method is expected to return an instance representing that template. The returned instance must supply a result method wich accepts a binding as its single argument. The result method is expected to return the rendered template as a string. A single template instance may have its result method invoked multiple times with different bindings.

Methods

Class

Visibility Signature
public add_template_directory (dir)
public file_extension (name)
public is_registered_extension? (ext)
public load_template (name)
public register_engine (extension, klass)
public registered_extensions ()
public template_directories ()
protected find_template_file (name)

Class Method Detail

add_template_directory(dir)

Add a template directory to search

file_extension(name)

Determine the extension for a filename (not including the leading dot)

is_registered_extension?(ext)

Determine if a given extension is a registered extension

load_template(name)

Load a template and return its instance

register_engine(extension, klass)

Register a template engine for an extension

registered_extensions()

Return the list of registered extensions

template_directories()

Return the list of template directories

find_template_file(name)

Determine the filename for a template