O'Reilly logo

HTML5 Data and Services Cookbook by Mite Mitreski, Gorgi Kosev

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Reusing templates with partials in EJS

Partial templates are larger sections of HTML which need to be included multiple times from multiple pages. Common uses for partial templates include headers, footers, site menus, login boxes, alerts, and so on.

The latest version of EJS doesn't natively support partial templates; they have been removed. However, there is another way to use other templates from within a template, by including the compiled template itself in the data model.

In this recipe, we're going to render a conversation thread using a recursive partial template written in EJS.

Getting ready

We need to download EJS from http://embeddedjs.com/ and extract ejs_production.js in our recipe folder.

How to do it...

Let's get started.

  1. Create index.html ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required