views.js 5.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /**
  2. * View Engine Configuration
  3. * (sails.config.views)
  4. *
  5. * Server-sent views are a classic and effective way to get your app up
  6. * and running. Views are normally served from controllers. Below, you can
  7. * configure your templating language/framework of choice and configure
  8. * Sails' layout support.
  9. *
  10. * For more information on views and layouts, check out:
  11. * http://sailsjs.org/#/documentation/concepts/Views
  12. */
  13. module.exports.views = {
  14. /****************************************************************************
  15. * *
  16. * View engine (aka template language) to use for your app's *server-side* *
  17. * views *
  18. * *
  19. * Sails+Express supports all view engines which implement TJ Holowaychuk's *
  20. * `consolidate.js`, including, but not limited to: *
  21. * *
  22. * ejs, jade, handlebars, mustache underscore, hogan, haml, haml-coffee, *
  23. * dust atpl, eco, ect, jazz, jqtpl, JUST, liquor, QEJS, swig, templayed, *
  24. * toffee, walrus, & whiskers *
  25. * *
  26. * For more options, check out the docs: *
  27. * https://github.com/balderdashy/sails-wiki/blob/0.9/config.views.md#engine *
  28. * *
  29. ****************************************************************************/
  30. engine: 'handlebars',
  31. /****************************************************************************
  32. * *
  33. * Layouts are simply top-level HTML templates you can use as wrappers for *
  34. * your server-side views. If you're using ejs or jade, you can take *
  35. * advantage of Sails' built-in `layout` support. *
  36. * *
  37. * When using a layout, when one of your views is served, it is injected *
  38. * into the `body` partial defined in the layout. This lets you reuse header *
  39. * and footer logic between views. *
  40. * *
  41. * NOTE: Layout support is only implemented for the `ejs` view engine! *
  42. * For most other engines, it is not necessary, since they implement *
  43. * partials/layouts themselves. In those cases, this config will be *
  44. * silently ignored. *
  45. * *
  46. * The `layout` setting may be set to one of the following: *
  47. * *
  48. * If `false`, layouts will be disabled. Otherwise, if a string is *
  49. * specified, it will be interpreted as the relative path to your layout *
  50. * file from `views/` folder. (the file extension, ".ejs", should be *
  51. * omitted) *
  52. * *
  53. ****************************************************************************/
  54. /****************************************************************************
  55. * *
  56. * Using Multiple Layouts *
  57. * *
  58. * If you're using the default `ejs` or `handlebars` Sails supports the use *
  59. * of multiple `layout` files. To take advantage of this, before rendering a *
  60. * view, override the `layout` local in your controller by setting *
  61. * `res.locals.layout`. (this is handy if you parts of your app's UI look *
  62. * completely different from each other) *
  63. * *
  64. * e.g. your default might be *
  65. * layout: 'layouts/public' *
  66. * *
  67. * But you might override that in some of your controllers with: *
  68. * layout: 'layouts/internal' *
  69. * *
  70. ****************************************************************************/
  71. layout: false,
  72. /****************************************************************************
  73. * *
  74. * Partials are simply top-level snippets you can leverage to reuse template *
  75. * for your server-side views. If you're using handlebars, you can take *
  76. * advantage of Sails' built-in `partials` support. *
  77. * *
  78. * If `false` or empty partials will be located in the same folder as views. *
  79. * Otherwise, if a string is specified, it will be interpreted as the *
  80. * relative path to your partial files from `views/` folder. *
  81. * *
  82. ****************************************************************************/
  83. partials: false
  84. };