Namespace mmir.parser
Defined in: parserModule.js.
Constructor Attributes | Constructor Name and Description |
---|---|
This module holds functions / classes for template parsing.
|
Method Attributes | Method Name and Description |
---|---|
<static> |
mmir.parser.appendStringified(obj, propertyNames, stringBuffer, propertyNamePostfix, valueFunc)
Creates String-representations (JSON-like) for the specified properties and appends them to the StringBuffer.
|
<static> |
mmir.parser.restoreObject(storedObject, isTriggerPublish, fileFormatNo)
Creates the appropriate object from a JSON-like storedObject.
|
This module contains definitions for constants used in the Template Parser and Renderer.
//access the parser module // (it is a sub-module of mmir!) var someConst = mmir.parser.element.INCLUDE_SCRIPT; ...
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. by stringBuffer.join('')
.
Defined in: storageUtils.js.
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\","
- Parameters:
- {Object} obj
- the object, that contains the properties for which String representations should be generated.
-
{Array
} propertyNames - the names of the properties, for which String-representations should be generated.
-
{Array
} stringBuffer - the buffer: String-representations will be appended as entries at the end of the buffer
- {String} propertyNamePostfix 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.
- {Function} valueFunc 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:
- {Array
} the modified stringBuffer
- Requires:
- JSON.stringify
NOTE that in difference to a real JSON object, the storedObject may contain function definitions.
The storedObject must have a String property classConstructor
- that must correspond to a constructor function (which will be invoked with new)
- the constructor function must be invokable without parameters
- the constructor function must be accessable from the global namespace (or classConstuctor must contain the code for retrieving the constructor function from the global namespace)
If storedObject contains a function init, then this function will be invoked
before returning the new newly created object.
Defined in: storageUtils.js.
- Parameters:
- {Object} storedObject
- a JSON-like object with fields and functions (which will be transfered to the returned object).
- {Boolean} isTriggerPublish 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). - {Number} fileFormatNo Optional
- OPTIONAL
NOTE: if argument
isTriggerPublish
was used with valuetrue
, then this argument MUST be used too! If the number given does not match parser.STORAGE_FILE_FORMAT_NUMBER the file format is assumed to be out-dated and an Error will be thrown.
- Throws:
- Error if
fileFormatNo
does not match STORAGE_FILE_FORMAT_NUMBER.
- Returns:
- {Object} an new instance created with the constructor classConstructor and set with all properties (fields and functions) from storedObject.