TemplateParser

Moduleejs.template
Definition class TemplateParser
InheritanceTemplateParser inherit Object
Specifiedejscript-2.5
StabilityPrototype (.

Web Page Template Parser - Parse an ejs web page and emit an Ejscript source file (.es).

This parser handles embedded Ejscript using <% %> directives. It supports:

  • <% Begin an ejs directive section containing statements
  • <%= Begin an ejs directive section that contains an expression to evaluate and substitute
  • %> End an ejs directive
  • <%@ include "file" %> Include an ejs file
  • <%@ layout "file" %> Specify a layout page to use. Use layout "" to disable layout management.
  • <%@ view "[module::]class" %> Specify a view class to use with optional module.
  • <%@ content Mark the location to substitute content in a layout page
Directives for use outside of <% %>
  • @@var — To expand the value of "var". Var can also be simple expressions (without spaces).


Properties

(No own properties defined)


TemplateParser Class Methods

(No own class methods defined)

QualifiersMethod

TemplateParser Instance Methods

QualifiersMethod
build(script: String, options: Object = expression): String
 Build a templated page.
parse(script: String, options: Object = expression): String
 Template parser.

Method Detail

build(script: String, options: Object = expression): String
Description
Build a templated page.
Parameters
script: String String containing the script to parse.
options: Object Object hash with options to control parsing. [default: expression]
Options
layoutPath Layout file.
dirPath Base directory to use for including files and for resolving layout directives.

parse(script: String, options: Object = expression): String
Description
Template parser. Parse the given script and return the compiled (Ejscript) result.
Parameters
script: String String containing the script to parse.
options: Object Object hash with options to control parsing. [default: expression]
Options
layoutPath Layout file.
dirPath Base directory to use for including files and for resolving layout directives.
Returns
The parsed and expanded template P.