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.ContentElementobject.During rendering, the view's template-expressions are evaluated, and the results rendered into the returned String.
Name Type Description contentElementmmir.view.ContentElement the ContentElement object that should be rendered dataObject optional a JSON object which's fields will be available during rendering/evaluation of the template expressions renderingBufferArray.<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 rawJSSourceCodeString the original JavaScript source code replacementObjectsListArray.<mmir.parser.ParsingResult> isForcePrefixBoolean 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 parseResultmmir.parser.ParsingResult the parsed view template contentForArrayArray.<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 htmlContentStringString | mmir.view.ContentElement the original view-content of the layout-template text, see mmir.view.Layout#getBodyContentsor a ContentElement with its YieldDeclarations in its allContentElements field (by default yields are not contained in ContentElement.allContentElements)yieldDeclarationsArrayArray.<mmir.view.YieldDeclaration> a list of yield-declarations of the layout contentForObjectsArrayArray.<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. dataObject 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 htmlContentStringString the original dialog-content of the layout-template text, see mmir.view.Layout#getDialogsContentsmmir.view.YieldDeclaration[]}yieldDeclarationsArray a list of yield-declarations of the layout contentForObjectsArrayArray.<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. dataObject 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