Class: RenderUtils

mmir.parser. RenderUtils

mmir.parser.RenderUtils

A Utility class for rendering parsed (eHTML) templates, or more specifically ParsingResult objects.
Example
mmir.parser.RenderUtils.render(parseResult, contentElementList);

Members

privateDATA_NAME

privateinstanceRenderUtils

Object containing the instance of the class RenderUtils

privatelocalizermmir.LanguageManager

privateloggermmir.tools.Logger

the logger for the RenderUtils

privatePARAM_ARGS_NAME

privatePARAM_DATA_NAME

privateRENDER_MODE_JS_SOURCE

privateRENDER_MODE_JS_SOURCE_FORCE_VAR_PREFIX

privateRENDER_MODE_LAYOUT

privateRENDER_MODE_PARTIAL

privateRENDER_MODE_VIEW_CONTENT

privateRENDER_MODE_VIEW_DIALOGS

privaterenderContentElementImpl

Renders a ContentElement object into the renderingBuffer.

privaterenderJSSourceImpl

Prepares JavaScript source code for usage in rendering the template (view/partial etc.). The replacement-list contains information which parts of the raw JavaScript code should be modified (e.g. indices [start,end] for replacing text in the source code). The function returns the modified JavaScript source code as a String. If the mode is RENDER_MODE_JS_SOURCE_FORCE_VAR_PREFIX, the variable-names that correspond to replacementObjectsList are check: if a name does not start with @, then the name will prepended with @ before rendering.

privaterenderLayoutImpl

Prepares the layout: after loading a layout file, this methods prepares the layout for rendering content into it (i.e. "prepare layout definition for later view-renderings"). NOTE: this does not actually render the layout for "viewing" (see renderContent(..))!

Methods

privatecreateInternalData()

HELPER for creating the data-object

privategetContentForYield()

privategetRenderingBuffer(){Array}

HELPER creates a new rendering buffer if neccessary
Returns:
Type Description
Array rendering buffer
HELPER for detecting if an object is an Array
See:

renderContentElement(contentElement, data, renderingBuffer){String}

Renders a single mmir.view.ContentElement object.

During rendering, the view's template-expressions are evaluated, and the results rendered into the returned String.

Name Type Description
contentElement mmir.view.ContentElement the ContentElement object that should be rendered
data Object optional a JSON object which's fields will be available during rendering/evaluation of the template expressions
renderingBuffer Array.<String> optional if provided, the partial rendering results will be appended to this Array
Returns:
Type Description
String the evaluated and rendered ContentElement; if renderingBuffer was provided and not empty, the result will be prepended with the concatenated contents of the Array's Strings

privaterenderContentImpl(htmlContentString, yieldDeclarationsArray, contentForObjectsArray, renderingMode, data){String}

Render a View Renders the contents into a layout definition (i.e. "render for viewing").
Name Type Description
htmlContentString String the "raw" content string that was parsed
yieldDeclarationsArray Array.<mmir.view.YieldDeclaration> a list of yield-declarations for the parsed htmlContentString
contentForObjectsArray Array.<mmir.view.ContentElement> a list of content-for objects for the parsed htmlContentString. This list must supply a corresponding object for each entry in the yieldDeclarationsArray.
renderingMode Number the render mode
data Object the rendering data
Returns:
Type Description
String the evaluated and rendered view-content

privaterenderElement(containingContentElement)

Name Type Description
containingContentElement

privaterenderIncludeScript()

privaterenderIncludeStyle()

renderJS(rawJSSourceCode, replacementObjectsList, isForcePrefix)

Prepares JavaScript source code for usage in rendering the template (view/partial etc.). The replacement-list contains information which parts of the raw JavaScript code should be modified (e.g. indices [start,end] for replacing text in the source code). The function returns the modified JavaScript source code as a String. If the mode is isForcePrefix == true, the variable-names that correspond to replacementObjectsList are check: if a name does not start with @, then the name will prepended with @ before rendering.
Name Type Description
rawJSSourceCode String the original JavaScript source code
replacementObjectsList Array.<mmir.parser.ParsingResult>
isForcePrefix Boolean optional

renderLayout(parseResult, contentForArray){String}

Renders a layout in preparation for displaying content: This function should be used to preperare the layout content, so that its views can be rendered into it (needs to be done only once, after the layout is loaded).
Name Type Description
parseResult mmir.parser.ParsingResult the parsed view template
contentForArray Array.<mmir.view.ContentElement> optional
Returns:
Type Description
String the prepared layout content

privaterenderLocalize()

privaterenderScriptBlock()

privaterenderScriptStatement()

privaterenderVarDeclaration()

privaterenderVarReference()

renderViewContent(htmlContentString, yieldDeclarationsArray, contentForObjectsArray, data){String}

Renders a view.

During rendering, the view's template-expressions are evaluated, and the results rendered into the returned String.

Name Type Description
htmlContentString String | mmir.view.ContentElement the original view-content of the layout-template text, see mmir.view.Layout#getBodyContents or a ContentElement with its YieldDeclarations in its allContentElements field (by default yields are not contained in ContentElement.allContentElements)
yieldDeclarationsArray Array.<mmir.view.YieldDeclaration> a list of yield-declarations of the layout
contentForObjectsArray Array.<mmir.view.ContentElement> a list of content-for objects of the view. This list must supply a corresponding objecet for each entry in the yieldDeclarationsArray.
data Object optional OPTIONAL a JSON object which's fields will be available during rendering/evaluation of the template expressions
Returns:
Type Description
String the evaluated and rendered view-content

renderViewDialogs(htmlContentString, contentForObjectsArray, data){String}

Renders the dialog content for a view.

During rendering, the view's template-expressions are evaluated, and the results rendered into the returned String.

Name Type Description
htmlContentString String the original dialog-content of the layout-template text, see mmir.view.Layout#getDialogsContents
mmir.view.YieldDeclaration[]} yieldDeclarationsArray a list of yield-declarations of the layout
contentForObjectsArray Array.<mmir.view.ContentElement> a list of content-for objects of the view. This list must supply a corresponding objecet for each entry in the yieldDeclarationsArray.
data Object optional a JSON object which's fields will be available during rendering/evaluation of the template expressions
Returns:
Type Description
String the evaluated and rendered dialog-content

privatesortAscByStart()

helper for sorting an Arrays. Notes: 1. all array elements must have a function {Number} getStart() 2. the array will be sorted ascending by getStart(), e.g. sort by occurrence in the raw template-text Usage example: theArray.sort(sortAscByStart);