Chapter 5. Its All About the View

The UI layer, or View, is the most visible component of any application. No matter what is going on underneath the hood, be it REST, Websockets, MQTT, or SOAP, the view is where everything culminates for a full, interactive application experience. Just as with the server side, the view has its own set of complexities and myriad of architectural choices to make from a development perspective. We will now explore some of these choices along with some different design patterns that can be used in the all-encompassing view layer.

In this chapter, we will cover the following images:

  • The differences among various JavaScript templating engines
  • The advantages of precompiling JavaScript templates
  • How to optimize your application layout

JavaScript templating engines

Maintaining the view on the frontend of your application goes a long way toward keeping it server-side agnostic. Even if you are using a MVC framework underneath to serve REST endpoints for your application, keeping the view templates and logic on the frontend will ensure that you can more easily swap out the MVC backend in the future without significantly altering the logical and architectural structure of your application. JavaScript templating engines provide an effective way to manage view templates entirely on the frontend.

There are many open source JavaScript templating engines available. Next, we will cover the basics of some of the more popular ones:

  • Underscore.js
  • Mustache.js
  • Handlebars.js
  • Pure.js
  • Pug
  • EJS
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.141.28.107