View on GitHub

reading-notes

Observations and questions from reading assignments.

EJS Partials

Home

Partials allow you to reuse the same HTML across multiple views. They make large websites easier to maintain as you don’t have to go and change a piece of text in every page it appears in. Instead, you define that reusable bundle of code in a file and include it wherever you need it.

The <%- %> tags allow us to output the unescaped content onto the page (notice the -). This is important when using the include() statement since you don’t want EJS to escape your HTML characters like ‘<’, ‘>’, etc…

Partials 1

Creating and including partials is very straightforward with EJS.

Partials 2

Source:

Hensle Josephe