mmir.parser.RenderUtils
A Utility class for rendering parsed (eHTML) templates, or more specifically ParsingResult objects.
Example
mmir.parser.RenderUtils.render(parseResult, contentElementList);
Methods
-
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 -
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 -
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