Configuration for your app's server-side views. The options are conventionally specified in the config/views.js configuration file.
| Property | Type | Default | Details |
|---|---|---|---|
layout |
"layout" |
Set the default layout for your app by specifying the relative path to the desired layout file from your views folder (i.e. views/.) Or disable layout support altogether with false. Built-in support for layouts is only relevant when using ejs (see below) |
|
engine |
"ejs" |
The view engine your app will use to compile server-side markup into HTML. | |
extension |
Same as engine |
The file extension for view files. | |
locals |
{} |
Default data to be included as view locals every time a server-side view is compiled anywhere in this app. If an optional locals argument was passed in directly via res.view(), its properties take precedence when both dictionaries are merged and provided to the view (more on that below) |
- If your app is NOT using
ejs(the default view engine) Sails will function as if thelayoutoption was set tofalse. To take advantage of layouts when using a custom view engine like Jade or Handlebars, check out that view engine's documentation to find the appropriate syntax.- As of Sails 0.12.0, app-wide locals from
sails.config.views.localsare combined with any one-off locals you use withres.view()using a shallow merge strategy. That is, if your app-wide locals configuration is{foo: 3, bar: { baz: 'beep' } }, and then you useres.view({bar: 'boop'}), your view will have access tofoo(3) andbar('boop').