Leverage Template Engines With ExpressJS and Mustache
Description
If you are building a web app using ExpressJS as your only technology stack, you should also need to create a frontend part. Because of this, you need to define HTML pages that will be rendered by your server. Most of the times, you want your pages to be dynamic, so as to be dynamically generated by your server.
ExpressJS has a built-in part to handle template engines. A template engine is an engine that compiles and inserts values into templates (such as HTML templates) you want to render to your users. There are different ExpressJS supported template engines. The most common are Pug, EJS, and Mustache.
In this lab, you will understand the core concept to integrate and use template engines in ExpressJS, and you will then define a simple template that will be populated and rendered by your ExpressJS application using Mustache.
Learning Objectives
Upon completion of this beginner level lab, you will be able to:
- Understand the principles of template engines in ExpressJS
- Integrate and use a template engine to render templates to the users
Intended Audience
- Software engineers that want to deep dive into the ExpressJS template engine system
- JavaScript developers that want to use ExpressJS both for the frontend and the backend part
Prerequisites
To get the most out of this lab, you should have basic knowledge of the ExpressJS framework. To achieve this, we suggest taking the following lab and courses: