This project is read-only.

Framework Architecture

RazorEngine is a simplified templating framework built around Microsoft's new Razor parsing engine, used in both ASP.NET MVC3 and Web Pages. RazorEngine provides a wrapper and additional services built around the parsing engine to allow the parsing technology to be used in other project types.

The core components that make up the templating mechanism are a compiler service and a template service. The compile service is defined as:

public interface ICompilerService
    string BuildTypeName(Type templateType, Type modelType);
    Type CompileType(TypeContext context);

The compiler service is responsible for transforming a text template (as defined in a TypeContext) into a compiled type using the Razor parser for code generation. When a type has been generated, it is instantiated through an activator:

public interface IActivator
    ITemplate CreateInstance(Type type);

An activator allows for the custom instantiation of a template instance. This functionality is managed through a TemplateService instance. A TemplateService provides additional functionality, such as templating caching and template resolution. Template resolution is the process of locating additional templates using @Include calls. A template resolver is defined as:

public interface ITemplateResolver
    string GetTemplate(string name);

A template resolver returns the unparsed template content of the template to include. This allows @Include calls to be resolved at execute time by providing a mechanism to locate named templates that may not have been parsed prior to the parent template executing.

Last edited Jan 23, 2011 at 5:08 PM by AntarisZX, version 2


No comments yet.