Constructor
new ViewEngineUnit(views_diropt)
Instantiate the unit class. Resolves the fully-qualified path to the views directory.
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
views_dir |
string |
<optional> |
'./app/views' | path to the views directory |
Extends
Members
(static) name
Get the name of the service provided by this unit: 'views'
(static) services
Defines the services required by this unit.
(private) _di_allow_defer :boolean
If true, the injector will defer the class if the class requests any services that the container is missing. These services are filled in later and added to the prototype and any instances. True by default.
- boolean
- Overrides:
- Source:
(private) _di_deferred_instances :Array.<module:flitter-di/src/Injectable~Injectable>
Collection of instances of this class that need to have the deferred service instances injected into them when the deferred services are finally provided.
- Source:
(private) _di_deferred_services :Array.<string>
List of services that were deferred and not provided at the time of injection.
- Array.<string>
- Source:
directory :string
The fully-qualified path to the views directory.
- string
Methods
(async) cleanup(app) → {Promise.<void>}
Cleans up the unit's resources before Flitter closes.
Name | Type | Description |
---|---|---|
app |
module:libflitter/app/FlitterApp~FlitterApp | the Flitter app |
- Overrides:
- Source:
- Type
- Promise.<void>
directories() → {Object}
Get the directories provided by this unit. Currently, "views" mapped to module:libflitter/views/ViewEngineUnit~ViewEngineUnit#directory.
- Overrides:
- Type
- Object
(async) error(response, status, params) → {Promise.<*>}
Sends an HTTP error and renders the error view with the corresponding status code. If the status code cannot be resolved to an integer, the request status will default to 400.
Name | Type | Description |
---|---|---|
response |
Express/Response | the Express response to be served |
status |
string | int | HTTP or error status code |
params |
Object | collection of arguments to be passed to the view. The "code" key will be overwritten with the status. |
- Type
- Promise.<*>
(async) go(app, context) → {Promise.<void>}
Loads the unit. Binds the view helper function to the global context and configures Express to use the Pug view engine.
Name | Type | Description |
---|---|---|
app |
module:libflitter/app/FlitterApp~FlitterApp | the Flitter app |
context |
module:libflitter/Context~Context | the unit's context |
- Overrides:
- Type
- Promise.<void>
migrations() → {string}
Get the fully-qualified path to the migrations provided by this unit.
- Type
- string
name() → {String}
Get the name of the unit. Should be a lowercase, alphanum/dash/underscore string.
- Overrides:
- Source:
- Type
- String
status(setopt) → {string}
Get or set the unit's current status.
Name | Type | Attributes | Description |
---|---|---|---|
set |
string |
<optional> |
if provided, set the status of the unit |
- Overrides:
- Source:
- current status of the unit
- Type
- string
(async) view(response, view_name, args, resource_list) → {Promise.<*>}
Render a view to the provided response. Passes through arguments and retrieves the specified resources for the view.
Name | Type | Description |
---|---|---|
response |
Express/Response | the Express response to be served |
view_name |
string | the Flitter canonical name of the view to be served |
args |
Object | collection of arguments to be passed directly to the view |
resource_list |
Array.<module:libflitter/views/ViewEngineUnit~ViewEngineUnit~ResourceSpec> | array of resource specifications to be retrieved and passed to the view |
- Type
- Promise.<*>