Book Image

Web Development with MongoDB and NodeJS Second edition

Book Image

Web Development with MongoDB and NodeJS Second edition

Overview of this book

Table of Contents (19 chapters)
Web Development with MongoDB and NodeJS Second Edition
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
12
Popular Node.js Web Frameworks
Index

Server-side and client-side templating


Templating solutions can be generally classified into two as client-side and server-side templating solutions. The web applications we build usually follow a server-side or client-side templating approach or even a hybrid of both.

Client-side templating

Imagine a case where the web application, after loading the page, makes an API call via AJAX and gets a JSON response in return. How will it render the data it received into its corresponding HTML? Client-side templates are required in this case to keep our JavaScript code neat and clean, or else we will end up putting too much unreadable HTML code as strings inside the JavaScript code. Client-side templating frameworks allow us to dump the templates corresponding to the components of a page in the markup inside specific tags and render them via JavaScript code whenever necessary. The common disadvantage of following a client-side approach is the impact it has on the initial render time of this page.

Another...