Back to Sails

sails.renderView()

docs/reference/application/advanced-usage/sails.renderView.md

12.12.20001.0 KB
Original Source

sails.renderView()

This feature is still experimental.

This method is still under development, and its interface and/or behavior could change at any time.

Compile a view into an HTML template.

usage
sails.renderView(pathToView, templateData);

Usage

 ArgumentTypeDetails
1pathToView((string))The path to the view that will be compiled into HTML.
2templateData((dictionary?))The dynamic data to pass into the view.

Example

To compile an HTML template with a customized greeting for the recipient:

javascript
var htmlEmailContents = await sails.renderView('emails/signup-welcome', {
  fullName: inputs.fullName,
  // Don't include the Sails app's default layout in the rendered template.
  layout: false
});
<docmeta name="displayName" value="sails.renderView()"> <docmeta name="pageType" value="method"> <docmeta name="isExperimental" value="true">