core/templates

Template renderer for Moodle. Load and render Moodle templates with Mustache.

Source:
Since:
  • 2.9
License:
  • http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Members

(inner) cachePartialPromises :Array.<Promise>

Source:

Cache of already loaded template partial promises

Type:
  • Array.<Promise>

(inner) disallowedNestedHelpers :Array

Source:

List of helpers that can't be called within other helpers

Type:
  • Array

(inner) iconSystem :Object

Source:

Object extending core/iconsystem

Type:
  • Object

(inner) isLoadingTemplates :Bool

Source:

Whether templates are currently being loaded

Type:
  • Bool

(inner) loadTemplateBuffer :Array.<Object>

Source:

List of templates to be loaded

Type:
  • Array.<Object>

(inner) requiredDates :Array.<object>

Source:

Collection of dates found during the rendering of one template

Type:
  • Array.<object>

(inner) requiredJS :Array.<string>

Source:

Collection of js blocks found during the rendering of one template

Type:
  • Array.<string>

(inner) requiredStrings :Array.<string>

Source:

Collection of strings found during the rendering of one template

Type:
  • Array.<string>

(inner) templateCache :Array.<String>

Source:

Cache of already loaded template strings

Type:
  • Array.<String>

(inner) templatePromises :Array.<Promise>

Source:

Cache of already loaded template promises

Type:
  • Array.<Promise>

(inner) themeName :String

Source:

for the current render

Type:
  • String

(inner) uniqInstances :Number

Source:

Count of times this constructor has been called.

Type:
  • Number

Methods

(inner) appendNodeContents(element, html, js) → {Array}

Source:

Append some HTML to a node and trigger events and fire javascript.

Parameters:
Name Type Description
element jQuery | String

Element or selector to append HTML to

html String

HTML to append

js String

Javascript to run after we append the html

Returns:

The list of new DOM Nodes

Type
Array

(inner) getTemplate(templateNames, themeName) → {Promise}

Source:

Prefetch a set of templates without rendering them.

Parameters:
Name Type Description
templateNames Array

The list of templates to fetch

themeName String
Returns:
Type
Promise

(inner) prependNodeContents(element, html, js) → {Array}

Source:

Prepend some HTML to a node and trigger events and fire javascript.

Parameters:
Name Type Description
element jQuery | String

Element or selector to prepend HTML to

html String

HTML to prepend

js String

Javascript to run after we prepend the html

Returns:

The list of new DOM Nodes

Type
Array

(inner) renderIcon(key, component, title) → {Promise}

Source:

Every call to renderIcon creates a new instance of the class and calls renderIcon on it. This means each render call has it's own class variables.

Parameters:
Name Type Description
key string

Icon key.

component string

Icon component

title string

Icon title

Returns:

JQuery promise object resolved when the pix has been rendered.

Type
Promise

(inner) replaceNode(element, newHTML, newJS) → {Array}

Source:

Insert a node in the page with some new HTML and run the JS.

Parameters:
Name Type Description
element JQuery

Element or selector to replace.

newHTML String

HTML to insert / replace.

newJS String

Javascript to run after the insertion.

Returns:

The list of new DOM Nodes

Type
Array

(inner) replaceNodeContents(element, newHTML, newJS) → {Array}

Source:

Replace a node in the page with some new HTML and run the JS.

Parameters:
Name Type Description
element JQuery

Element or selector to replace.

newHTML String

HTML to insert / replace.

newJS String

Javascript to run after the insertion.

Returns:

The list of new DOM Nodes

Type
Array

(inner) runTemplateJS(source)

Source:

Execute a block of JS returned from a template. Call this AFTER adding the template HTML into the DOM so the nodes can be found.

Parameters:
Name Type Description
source string

A block of javascript.

(inner) runTemplateJS(source)

Source:

Execute a block of JS returned from a template. Call this AFTER adding the template HTML into the DOM so the nodes can be found.

Parameters:
Name Type Description
source string

A block of javascript.