diff --git a/src/content/api/4x/api/application/index.mdx b/src/content/api/4x/api/application/index.mdx index ebac8720b3..d943f12295 100644 --- a/src/content/api/4x/api/application/index.mdx +++ b/src/content/api/4x/api/application/index.mdx @@ -1286,7 +1286,7 @@ app.put('/', function (req: Request, res: Response) { - The name of the view to render. + The file path of the view to render (absolute or relative to the `views` setting). An object whose properties define local variables for the view. @@ -1301,6 +1301,12 @@ Returns the rendered HTML of a view via the `callback` function. It accepts an o that is an object containing local variables for the view. It is like [res.render()](/api/response/#resrender), except it cannot send the rendered view to the client on its own. +The `view` argument is resolved the same way as [res.render()](/api/response/#resrender). It can be +an absolute path, or a path relative to the `views` setting. If the path does not include an +extension, Express uses the `view engine` setting to determine the template file extension. For +example, with `app.set('views', './views')` and `app.set('view engine', 'pug')`, `app.render('email')` +renders the template at `views/email.pug`. + Think of `app.render()` as a utility function for generating rendered view strings. Internally diff --git a/src/content/api/5x/api/application/index.mdx b/src/content/api/5x/api/application/index.mdx index 88ceb19322..2b7b1a93cf 100644 --- a/src/content/api/5x/api/application/index.mdx +++ b/src/content/api/5x/api/application/index.mdx @@ -1195,7 +1195,7 @@ app.query('/search', (req: Request, res: Response) => { - The name of the view to render. + The file path of the view to render (absolute or relative to the `views` setting). An object whose properties define local variables for the view. @@ -1210,6 +1210,12 @@ Returns the rendered HTML of a view via the `callback` function. It accepts an o that is an object containing local variables for the view. It is like [res.render()](/api/response/#resrender), except it cannot send the rendered view to the client on its own. +The `view` argument is resolved the same way as [res.render()](/api/response/#resrender). It can be +an absolute path, or a path relative to the `views` setting. If the path does not include an +extension, Express uses the `view engine` setting to determine the template file extension. For +example, with `app.set('views', './views')` and `app.set('view engine', 'pug')`, `app.render('email')` +renders the template at `views/email.pug`. + Think of `app.render()` as a utility function for generating rendered view strings. Internally