This module contains definitions for constants used in the Template Parser and Renderer.
Example
//access the parser module
var someConst = mmir.require('mmirf/parserModule').element.INCLUDE_SCRIPT;
...
Classes
Members
-
static,constantmmir.parser.STORAGE_CODE_WRAP_PREFIX
-
Prefix for wrapping persisted objects:
- wraps code into a closure
- makes global namespace available as variable
global(seeSTORAGE_CODE_WRAP_PREFIXfor setting global namespace) - makes mmirf/core available as variable
mmir(if mmirf/core is present in global namespace) - makes mmirf/core's require function available as
require(if mmirf/core is present and has require function)
- See:
-
- mmir.grammar.GrammarConverter#getCodeWrapPrefix
-
static,constantmmir.parser.STORAGE_CODE_WRAP_SUFFIX
-
Suffix for wrapping persisted objects:
- sets global namespace to
window
- See:
-
- mmir.BaseGenerator#getCodeWrapSuffix
- sets global namespace to
-
static,constantmmir.parser.STORAGE_FILE_FORMAT_NUMBER
-
-
staticmmir.parser.stylesRootString
-
the root path for stylesheets: will be prepended to file-paths when rendering
@style(file-path)- Default Value:
- ""
Methods
-
Creates String-representations (JSON-like) for the specified properties and appends them to the StringBuffer.
This function iterates over the Array propertyNames: If a property with that name exists in obj, a JSON-like String-representation is generated and appended at the end of the array stringBuffer.
Multiple representations are separated by comma entry','in stringBuffer.
The last entry in stringBuffer is a comma entry','if at least one property entry was inserted in stringBuffer.NOTE that the String-representation inserted into stringBuffer may not have a 1:1 correspondence with properties (only the last entry is guaranteed to be
',', if a property was inserted).
For pratical use, the returned (or modified) stringBuffer should be converted into a String e.g. bystringBuffer.join('').Name Type Description objObject the object, that contains the properties for which String representations should be generated. propertyNamesArray.<String> the names of the properties, for which String-representations should be generated. stringBufferArray.<String> the buffer: String-representations will be appended as entries at the end of the buffer propertyNamePostfixString optional OPTIONAL if present, this postfix will be appended to each property name, before processing it. This is a convenience method, e.g. if all properties in propertyNames should end with the same String / postfix. valueFuncfunction optional OPTIONAL by default, value representations are generated using the JSON.stringifyfunction. If instead this argument is present, this function will be invoked for creating the string representation of the property-value. The function signature isvalueFunc(propertyName : String, propertyValue : Object) : String. If the function returnsvoid, then the corresponding property will not be added/stringified.Returns:
Type Description Array.<String> the modified stringBuffer Example
var obj = { some: "properties", including: function(arg1,arg2){ return 'functions' } }; var sb = mobileDS.parser.appendStringified(obj, ['some'], []); var str = sb.join(','); //str will be: "some:\"properties\"," -
staticmmir.parser.restoreObject(storedObject, isTriggerPublish, fileFormatNo){Object}
-
Creates the appropriate object from a JSON-like storedObject.
NOTE that in difference to a real JSON object, the storedObject may contain function definitions.
The storedObject must have a String property classConstructor (type
String)- that must correspond to a require'able module that represents a constructor function (which will be invoked with new)
- the require'able module must be represents a constructor function (which will be invoked with new)
- the constructor function must be invokable without parameters
If storedObject contains a function init, then this function will be invoked before returning the new newly created object.
Name Type Description storedObjectObject a JSON-like object with fields and functions (which will be transfered to the returned object). isTriggerPublishBoolean optional OPTIONAL if truethen the restore function callinitPublish()on the restored object before returning. This should only betruefor the root-object (e.g. the View-object or Partial-object; nested objects should NOT invoke restoreObject() with this argument set to true).fileFormatNoNumber optional OPTIONAL NOTE: if argument isTriggerPublishwas used with valuetrue, then this argument MUST be used too! If the number given does not matchparser.STORAGE_FILE_FORMAT_NUMBERthe file format is assumed to be out-dated and an Error will be thrown.Throws:
Error iffileFormatNodoes not match STORAGE_FILE_FORMAT_NUMBER.Returns:
Type Description Object an new instance created with the constructor classConstructor and set with all properties (fields and functions) from storedObject.