Class: Template

Template

new Template(type, def, vars)

Object that wraps and abstracts the functionality of module:dot. It is meant to provide an enclosure for defines and vars so that they may persist and may be passed to the multiple functions returned by module:dot.template. Each property key of Template#def is also passed to these template functions to provide both compile time and run time access. The members of Template#vars also persist and are passed to the template function in the same way, but are not accessed the same way as Template#def in compile time. Every instance of this class is linked to a singleton TemplateSettings object. This link is made by the type string specified by Template#type.
Parameters:
Name Type Argument Description
type string <optional>
Value to set Template#type property.
def Object <optional>
Value to set Template#def property.
vars Object <optional>
Value to set Template#vars property.
Since:
  • 1.0
Source:
  • Template.js, line 80

Namespaces

settingsByType

Members

def :Object

Namespace to hold all defines when compiling data with this template.
Since:
  • 1.0
Default Value:
  • new Object()
Source:
  • Template.js, line 107

previousValidationCode :int

The value of the TemplateSettings#validateCode property of this instance's Template#settings object, which is set before invoking Template#process.
Since:
  • 1.0
Default Value:
  • null
Source:
  • Template.js, line 139

<readonly> settings :TemplateSettings

The settings object associated to this object by Template#type. These settings are a member and retrieved from Template.settingsByType.
Since:
  • 1.0
Default Value:
Source:
  • Template.js, line 148

type :string

The type string passed to this instance's constructor. This value must exist as a key in Template.settingsByType.
Since:
  • 1.0
Default Value:
  • "txt"
Source:
  • Template.js, line 160

vars :Object

Namespace to hold additional vars to be passed to the runtime runtime. These are in addition to, but will not override any defines set with the same name.
Since:
  • 1.0
Default Value:
  • new Object()
Source:
  • Template.js, line 118

Methods

destroy() → {void}

Removes all instance properties.
Since:
  • 1.0
Source:
  • Template.js, line 221
Returns:
Type
void

process(data, vars, thisObj) → {string}

Wrapper around the function returned by module:dot.template.
Parameters:
Name Type Argument Description
data string
vars Object <optional>
Value to set Template#vars property.
thisObj Object <optional>
Object to call function returned by module:dot.template
Since:
  • 1.0
Source:
  • Template.js, line 186
Returns:
The data ran through the template.
Type
string