Class ContentElement
Defined in: contentElement.js.
Constructor Attributes | Constructor Name and Description |
---|---|
ContentElement(group, view, parser, renderer)
The ContentElement represents "content" parts of a view; it may itself contain one or more ContentElements.
|
Field Attributes | Field Name and Description |
---|---|
<private> |
create ALL array and sort it, i.e.
|
<private> |
The ParsingResult that represents this ContentElement
|
<private> <constant> |
dummy name, if the ContentElement does not have a name:
only ContentElements that represent Views and Partials have names -
other sub-elements (@if,@for etc) do not have their own name/identifier.
|
The "raw" template text.
|
|
List of the "localize" statements in the template.
|
|
the "localizer" i.e.
|
|
Method Attributes | Method Name and Description |
---|---|
<private> |
checkHasDynamicContent(contentElement)
HELPER check if a ContentElement has "dynamic content"
|
<private> |
createJSEvalFunction(strFuncBody, strFuncName)
HELPER: this creates a function for embedded JavaScript code:
using a function pre-compiles codes - this avoids (re-) parsing the code
(by the execution environment) each time that the template is rendered.
|
Gets the controller for this ContentElement.
|
|
getEnd()
|
|
getName()
Gets the name of a mmir.ContentElement object (content, header, footer, dialogs, .
|
|
getStart()
|
|
getView()
Gets the owner for this ContentElement, i.e.
|
|
<private> |
sortAscByStart(parsedElem1, parsedElem2)
HELPER sorting function -> sort elements by occurrence in raw template text
|
create a String representation for this content element.
|
|
toHtml()
Gets the definition of a mmir.ContentElement object.
|
|
toStrings(renderingBuffer, data)
Renders this object into the renderingBuffer.
|
Class Detail
ContentElement(group, view, parser, renderer)
The ContentElement represents "content" parts of a view; it may itself contain one or more ContentElements.
This class holds the name of the content-field (used via the yield-tag in the layouts: content, header, footer, dialogs, ...)
and its definition as HTML-String.
- Parameters:
- {Array|Object} group
- an array or object with properties
name
{String}, andcontent
{String} - {Object} view
- the view that owns this ContentElement-element
- {mmir.parser.ParserUtils} parser
- for the the content (optional) if supplied this object must have a function
parse({String})
(see templateParseUtil) - {mmir.parser.RenderUtils} renderer
- for the the content (optional) if supplied, a
parser
must also be supplied; the renderer must have a functionparse({String})
(see templateRenderUtil)
Field Detail
<private>
{Array}
ContentElement-all
create ALL array and sort it, i.e. for localizations etc. ...
<private>
{mmir.parser.ParsingResult}
ContentElement-parsingResult
The ParsingResult that represents this ContentElement
<private> <constant>
ContentElement-SUB_ELEMENT_NAME
dummy name, if the ContentElement does not have a name:
only ContentElements that represent Views and Partials have names -
other sub-elements (@if,@for etc) do not have their own name/identifier.
TODO externalize as constant
{mmir.parser.ParsingResult}
this.comments
- See:
- mmir.parser.element.COMMENT
{String}
this.definition
The "raw" template text.
{mmir.parser.ParsingResult}
this.escapes
- See:
- mmir.parser.element.ESCAPE_ENTER
- mmir.parser.element.ESCAPE_EXIT
{mmir.parser.ParsingResult}
this.fors
- See:
- mmir.parser.element.FOR
{mmir.parser.ParsingResult}
this.helpers
- See:
- mmir.parser.element.HELPER
{mmir.parser.ParsingResult}
this.ifs
- See:
- mmir.parser.element.IF
{mmir.parser.ParsingResult}
this.localizations
List of the "localize" statements in the template.
- See:
- mmir.parser.element.LOCALIZE
{mmir.LanguageManager}
this.localizer
the "localizer" i.e. for handeling internationalization / localized Strings
{mmir.parser.ParsingResult}
this.scriptBlocks
- See:
- mmir.parser.element.BLOCK
{mmir.parser.ParsingResult}
this.scriptStatements
- See:
- mmir.parser.element.STATEMENT
{mmir.parser.ParsingResult}
this.vars
- See:
- mmir.parser.element.VAR_DECLARATION
Method Detail
<private>
checkHasDynamicContent(contentElement)
HELPER check if a ContentElement has "dynamic content"
- Parameters:
- contentElement
<private>
{Function}
createJSEvalFunction(strFuncBody, strFuncName)
HELPER: this creates a function for embedded JavaScript code:
using a function pre-compiles codes - this avoids (re-) parsing the code
(by the execution environment) each time that the template is rendered.
- Parameters:
- {String} strFuncBody
- the JavaScript code for the function body
- {String} strFuncName
- the name for the function
- Returns:
- {Function} the evaluated function with one input argument (see
DATA_NAME
)
{mmir.Controller}
getController()
Gets the controller for this ContentElement.
- Returns:
- {mmir.Controller} the Controller of the owning view
{String}
getDefinition()
- Deprecated:
- use #getRawText instead
- Returns:
- {String} the raw text from which this content element was parsed
- See:
- #getRawText
{Number}
getEnd()
- Returns:
- {Number} the end position for this content Element within #getRawText
{String}
getName()
Gets the name of a mmir.ContentElement object (content, header, footer, dialogs, ...).
- Returns:
- {String} Name - used by yield tags in layout
{String}
getRawText()
- Returns:
- {String} the raw text from which this content element was parsed
- See:
- #getDefinition
{Number}
getStart()
- Returns:
- {Number} the start position for this content Element within #getRawText
{mmir.View}
getView()
Gets the owner for this ContentElement, i.e. the mmir.View object.
- Returns:
- {mmir.View} the owning View
{Boolean}
hasDynamicContent()
- Returns:
- {Boolean} returns
true
if this ContentElement conatains dynamic content, i.e. if it needs to be "evaluated" for rendering (otherwise, its plain text representation can be used for rendering)
<private>
sortAscByStart(parsedElem1, parsedElem2)
HELPER sorting function -> sort elements by occurrence in raw template text
- Parameters:
- parsedElem1
- parsedElem2
{String}
stringify()
create a String representation for this content element.
- Returns:
- {String} the string-representation
- Requires:
- StorageUtils
- RenderUtils
{String}
toHtml()
Gets the definition of a mmir.ContentElement object.
TODO remove this?
- Returns:
- {String} The HTML content.
{Array}
toStrings(renderingBuffer, data)
Renders this object into the renderingBuffer.
- Parameters:
- renderingBuffer
- {Array} of Strings (if
null
a new buffer will be created) - data
- {Any} (optional) the event data with which the rendering was invoked
- Returns:
- {Array
} of Strings the renderingBuffer with the contents of this object added at the end