module:core/local/templates/renderer

module:core/local/templates/renderer

new (require("core/local/templates/renderer"))()

Source:

Constructor

Each call to templates.render gets it's own instance of this class.

Members

(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) themeName :String

Source:

for the current render

Type:
  • String

(inner) uniqInstances :Number

Source:

Count of times this constructor has been called.

Type:
  • Number

Methods

(static) getLoader() → {Loader}

Source:

Get the Loader used to fetch templates.

Returns:
Type
Loader

(static) setLoader(loader)

Source:

Set the template loader to use for all Template renderers.

Parameters:
Name Type Description
loader Loader

addHelperFunction(helperFunction, context) → {function}

Source:

Return a helper function to be added to the context for rendering the a template.

This will parse the provided text before giving it to the helper function in order to remove any disallowed nested helpers to prevent one helper from calling another.

In particular to prevent the JS helper from being called from within another helper because it can lead to security issues when the JS portion is user provided.

Parameters:
Name Type Description
helperFunction function

The helper function to add

context object

The template context for the helper function

Returns:

To be set in the context

Type
function

(async) processRenderedContent(renderedContent) → {Promise.<object.<string, string>>}

Source:

Process the rendered content, treating any strings and applying and helper strings, dates, etc.

Parameters:
Name Type Description
renderedContent string
Returns:

The rendered HTML and JS.

Type
Promise.<object.<string, string>>

(async) setupIconSystem()

Source:

Helper to set up the icon system.

treatDatesInContent(content, dates) → {String}

Source:

Treat strings in content.

The purpose of this method is to replace the date placeholders found in the content with the their respective translated dates.

Parameters:
Name Type Description
content String

The content in which string placeholders are to be found.

dates Array

The dates to replace with.

Returns:

The treated content.

Type
String

treatStringsInContent(content, stringMap) → {String}

Source:

Treat strings in content.

The purpose of this method is to replace the placeholders found in a string with the their respective translated strings.

Previously we were relying on String.replace() but the complexity increased with the numbers of strings to replace. Now we manually walk the string and stop at each placeholder we find, only then we replace it. Most of the time we will replace all the placeholders in a single run, at times we will need a few more runs when placeholders are replaced with strings that contain placeholders themselves.

Parameters:
Name Type Description
content String

The content in which string placeholders are to be found.

stringMap Map

The strings to replace with.

Returns:

The treated content.

Type
String