-
Book Overview & Buying
-
Table Of Contents
Backbone.js Patterns and Best Practices
By :
With AMD, we simplified the template organization process, but the end result still remains an uncompiled template string. In Chapter 2, Working with Views, we saw how template compilation affects application performance every time and we also analyzed the benefits of precompiling templates. Won't it be useful if we have something that will load these template files and provide us with an already-compiled template string instead? Fortunately, there are multiple tpl plugins available for Require.js that automate template compilation, and you can use these plugins directly in your module definition. Let us look at a similar plugin (https://github.com/ZeeAgency/requirejs-tpl) developed by ZeeAgency. Dependency loading is exactly the same as it is for the text plugin, you just need to use the tpl! plugin prefix instead of text!:
define(['tpl!your-template-path.tpl'], function (template) {
return template ({
your: 'data'
});
});Now, r.js provides...
Change the font size
Change margin width
Change background colour