Class: ViewLoader

ViewLoader

mmir.env.view.ViewLoader

Members

protectedisUsePreCompiledViewsBoolean

Flag for determining if pre-compiled views (*.js) should be used Reads property CONFIG_PRECOMPILED_VIEWS_MODE. If the property is not set, false is used by default, i.e. no pre-compiled views are used.
Default Value:
  • false: use templates files (*.ehtml) and compile them (freshly) on-the-fly

Methods

staticmmir.env.view.ViewLoader.loadViews(_instance, _layouts, _views, _partials, createViewKey, createPartialKey){Promise}

Loads views (layouts and partials): either compiled views (i.e. JS files), or raw views (i.e. eHTML files). The loader checks, if compiled views are up-to-date (using the corresponding checksum file). If a compiled view is not up-to-date (or its checksum file is missing), then the raw view will be loaded and compiled. If raw views are loaded, the parsing-module will loaded for compiling the views (i.e. if only compiled views are loaded, the dependency for the template parser and renderer is not required).
Configuration (configuration.json)
The configuration value "usePrecompiledViews" (Boolean) allows the determine, if views should always be compiled from the eHTML files (even if up-to-date compiled views are present). For example, configuration "usePrecompiledViews": true will use compiled views, while "usePrecompiledViews": false will always compile the eHTML files. If the configuration value for mmir.PresentationManager.CONFIG_DEFAULT_LAYOUT_NAME is set to NULL no default layout will be loaded. If mmir.PresentationManager.CONFIG_DEFAULT_LAYOUT_NAME is a non-empty string, then the corresponding layout will be used as default layout, instead of mmir.PresentationManager.DEFAULT_LAYOUT_NAME.
Name Type Description
_instance PresentationManager the instance of the PresentationManager
_layouts Map.<string, Layout> the layout collection of the PresentationManager for adding loaded layouts
_views Map.<string, View> the view collection of the PresentationManager for adding loaded views
_partials Map.<string, Partial> the partials collection of the PresentationManager for adding loaded partials
createViewKey function the PresentationManager's helper function for creating keys to be used when adding views to _views:
createViewKey(ctrl: {mmir.ctrl.Controller|String}, view: {mmir.view.View|String}) : {String}
createPartialKey function the PresentationManager's helper function for creating keys to be used when adding partials to _partials:
createPartialKey(partial: {mmir.view.Partial|String}, view: {mmir.view.View|String}) : {String}
Returns:
Type Description
Promise a deferred promise that gets resolved when the views (layouts, and partials) are loaded