/workspace/mergeTemplates
The workspace is cached in the module scope to allow for the mergeObjectTemplates(layer) method to assign template objects defined in a JSON layer to the workspace.templates{}.
Requires
Methods
(inner) assignWorkspaceTemplates(obj)
The method parses an object for a template object property. The template property value will be assigned to the workspace.templates{} object matching the template key value.
The template._type property will be set to 'template' indicating that the templates origin is in the workspace. It is possible to overassign _type:'core' templates which are loaded from the /mod/workspace/templates directory.
The method will call itself for nested objects.
Name | Type | Description |
---|---|---|
obj | Object |
(async, inner) mergeTemplates(obj) → {Promise}
The mergeTemplates method will be called for a layer or locale obj.
The locale or layer object will be merged with a template defined as obj.template string property.
The method will check for a template matching the obj.key string property if obj.template is undefined.
An array of templates can be defined as obj.templates[]. The templates will be merged into the obj in the order the template keys are in the templates[] array.
Name | Type | Description |
---|---|---|
obj | Object |
Name | Type | Attributes | Description |
---|---|---|---|
obj.template | string | <optional> | Key of template for the object. |
obj.key | string | Fallback for lookup of template if not an implicit property. | |
obj.templates | array | <optional> | An array of template keys to be merged into the object. |
The layer or locale provided as obj param.
- Type:
- Promise