Modularizing templates

Until now, templates have been declared as script tags in the index.html file. While this is a good approach for small projects, it is not a good idea to put all your templates directly in the HTML file.

With Browserify, you can extract all your template files into individual files, with the advantage of modularization and a cleaner index.html file. Another benefit of modularizing templates is that you can pre-compile all the templates, saving resources in your users' browsers.

With Browserify, you can modularize almost any template format: jade, Handlebars, Underscore, and so on. It uses a transformation process described in Figure 4.5. If you have worked with other bundler tools such as webpack, transformations are analogous ...

Get Mastering Backbone.js now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.