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_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 obj
Object the object, that contains the properties for which String representations should be generated. propertyNames
Array.<String> the names of the properties, for which String-representations should be generated. stringBuffer
Array.<String> the buffer: String-representations will be appended as entries at the end of the buffer propertyNamePostfix
String 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. valueFunc
function optional OPTIONAL by default, value representations are generated using the JSON.stringify
function. 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.parser.getCodeWrapPrefix(disableStrictMode){String}
-
Prefix for wrapping persisted objects:
- wraps code into a closure
- makes global namespace available as variable
global
(for 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)
Name Type Description disableStrictMode
Boolean optional OPTIONAL disable JavaScript strict mode in the generated view code Returns:
Type Description String the prefix code for generated grammars (i.e. prepend to generated grammar code) -
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 storedObject
Object a JSON-like object with fields and functions (which will be transfered to the returned object). isTriggerPublish
Boolean optional OPTIONAL if true
then the restore function callinitPublish()
on the restored object before returning. This should only betrue
for the root-object (e.g. the View-object or Partial-object; nested objects should NOT invoke restoreObject() with this argument set to true).fileFormatNo
Number optional OPTIONAL NOTE: if argument isTriggerPublish
was used with valuetrue
, then this argument MUST be used too! If the number given does not matchparser.STORAGE_FILE_FORMAT_NUMBER
the file format is assumed to be out-dated and an Error will be thrown.Throws:
Error iffileFormatNo
does 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. -
staticmmir.parser.STORAGE_CODE_WRAP_SUFFIX()
-
Suffix for wrapping persisted objects:
- sets global namespace to
window
(browser),self
(webworker) etc
- sets global namespace to