Skip to Main Content
Node for Front-End Developers
book

Node for Front-End Developers

by Garann Means
January 2012
Beginner content levelBeginner
60 pages
1h 18m
English
O'Reilly Media, Inc.
Content preview from Node for Front-End Developers

Chapter 4. Server-Side Templates

Most front-end developers have needed to work with server-side templates at some point. They may not have been called that—there was a time when these templates were simply called “PHP pages”, “JSPs”, or similar, before the push to apply separation of concerns on the web. These days it’s more common to see pages and views rendered by any back-end framework trimmed of as much business logic as possible.

Node is no different. Just as those other application frameworks need a way to separate the HTML produced from the data that populates it, so does ours. We want to be able to create a set of views loosely coupled to our application logic and have the application decide when to render them, and with what data.

Creating a Dynamic Page

Unlike other server frameworks, choosing Node does not implicitly choose the templating engine you’ll use for creating pages. There existed several templating engines for JavaScript when Node was created, and that number has only grown since. Thanks to Node, we now have a large number of server-side-only engines as well. Almost every JavaScript library of sufficient size offers a template engine, Underscore probably being the smallest, and there are many standalone options. Node frameworks also tend to have a default. Express uses Jade out of the box, for instance. It doesn’t really matter which you choose, as long as it meets your needs and is comfortable for you.

Some things you might look at when selecting a templating engine ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Professional Website Performance: Optimizing the Front-End and Back-End

Professional Website Performance: Optimizing the Front-End and Back-End

Peter Smith
Redux Quick Start Guide

Redux Quick Start Guide

James Lee, Tao Wei, Suresh Kumar Mukhiya

Publisher Resources

ISBN: 9781449329112Errata PageSupplemental Content