Skip to content

Commit f118e03

Browse files
docs: clarify template engine adapters (#2445)
Co-authored-by: Sebastian Beltran <bjohansebas@gmail.com>
1 parent bb571d8 commit f118e03

2 files changed

Lines changed: 10 additions & 8 deletions

File tree

src/content/docs/en/4x/guide/using-template-engines.mdx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Using template engines with Express
3-
description: Discover how to integrate and use template engines like Pug, Handlebars, and EJS with Express.js to render dynamic HTML pages efficiently.
3+
description: Discover how to integrate and use template engines like Pug, Handlebars-compatible engines, and EJS with Express.js to render dynamic HTML pages efficiently.
44
---
55

66
import Alert from '@components/primitives/Alert/Alert.astro';
@@ -10,15 +10,15 @@ A _template engine_ enables you to use static template files in your application
1010
variables in a template file with actual values, and transforms the template into an HTML file sent to the client.
1111
This approach makes it easier to design an HTML page.
1212

13-
The [Express application generator](/starter/generator) uses [Pug](https://pugjs.org/api/getting-started.html) as its default, but it also supports [Handlebars](https://www.npmjs.com/package/handlebars), and [EJS](https://www.npmjs.com/package/ejs), among others.
13+
The [Express application generator](/starter/generator) uses [Pug](https://pugjs.org/api/getting-started.html) as its default, but it can generate apps configured for Handlebars-compatible engines such as [hbs](https://www.npmjs.com/package/hbs), [EJS](https://www.npmjs.com/package/ejs), among others.
1414

15-
To render template files, set the following [application setting properties](/api/application/#appset), in the default `app.js` created by the generator:
15+
For apps created by the generator, these settings are added to the generated `app.js`. For apps you create without the generator, set the following [application setting properties](/api/application/#appset) yourself:
1616

1717
- `views`, the directory where the template files are located. Eg: `app.set('views', './views')`.
1818
This defaults to the `views` directory in the application root directory.
1919
- `view engine`, the template engine to use. For example, to use the Pug template engine: `app.set('view engine', 'pug')`.
2020

21-
Then install the corresponding template engine npm package; for example to install Pug:
21+
Then install the corresponding Express-compatible template engine npm package; for example to install Pug:
2222

2323
<PackageManagerCommand command="npm install pug --save" />
2424

@@ -28,6 +28,7 @@ which `res.render()` calls to render the template code.
2828

2929
Some template engines do not follow this convention. The [@ladjs/consolidate](https://www.npmjs.com/package/@ladjs/consolidate)
3030
library follows this convention by mapping all of the popular Node.js template engines, and therefore works seamlessly within Express.
31+
For example, install [hbs](https://www.npmjs.com/package/hbs) or any other Express-compatible Handlebars view engine instead of the raw `handlebars` package by itself.
3132

3233
</Alert>
3334

src/content/docs/en/5x/guide/using-template-engines.mdx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Using template engines with Express
3-
description: Discover how to integrate and use template engines like Pug, Handlebars, and EJS with Express.js to render dynamic HTML pages efficiently.
3+
description: Discover how to integrate and use template engines like Pug, Handlebars-compatible engines, and EJS with Express.js to render dynamic HTML pages efficiently.
44
---
55

66
import Alert from '@components/primitives/Alert/Alert.astro';
@@ -10,15 +10,15 @@ A _template engine_ enables you to use static template files in your application
1010
variables in a template file with actual values, and transforms the template into an HTML file sent to the client.
1111
This approach makes it easier to design an HTML page.
1212

13-
The [Express application generator](/starter/generator) uses [Pug](https://pugjs.org/api/getting-started.html) as its default, but it also supports [Handlebars](https://www.npmjs.com/package/handlebars), and [EJS](https://www.npmjs.com/package/ejs), among others.
13+
The [Express application generator](/starter/generator) uses [Pug](https://pugjs.org/api/getting-started.html) as its default, but it can generate apps configured for Handlebars-compatible engines such as [hbs](https://www.npmjs.com/package/hbs), [EJS](https://www.npmjs.com/package/ejs), among others.
1414

15-
To render template files, set the following [application setting properties](/api/application/#appset), in the default `app.js` created by the generator:
15+
For apps created by the generator, these settings are added to the generated `app.js`. For apps you create without the generator, set the following [application setting properties](/api/application/#appset) yourself:
1616

1717
- `views`, the directory where the template files are located. Eg: `app.set('views', './views')`.
1818
This defaults to the `views` directory in the application root directory.
1919
- `view engine`, the template engine to use. For example, to use the Pug template engine: `app.set('view engine', 'pug')`.
2020

21-
Then install the corresponding template engine npm package; for example to install Pug:
21+
Then install the corresponding Express-compatible template engine npm package; for example to install Pug:
2222

2323
<PackageManagerCommand command="npm install pug --save" />
2424

@@ -28,6 +28,7 @@ which `res.render()` calls to render the template code.
2828

2929
Some template engines do not follow this convention. The [@ladjs/consolidate](https://www.npmjs.com/package/@ladjs/consolidate)
3030
library follows this convention by mapping all of the popular Node.js template engines, and therefore works seamlessly within Express.
31+
For example, install [hbs](https://www.npmjs.com/package/hbs) or any other Express-compatible Handlebars view engine instead of the raw `handlebars` package by itself.
3132

3233
</Alert>
3334

0 commit comments

Comments
 (0)