Pro Grunt.js by James Cryer

Pro Grunt.js by James Cryer

Author:James Cryer [Cryer, James]
Language: eng
Format: azw3, epub, mobi, pdf
ISBN: 9781484200148
Publisher: Apress
Published: 2015-03-27T04:00:00+00:00


tagName: 'div',

className: 'todo-form',

template: Template["build/templates/form.hbs"],

render: function() {

var title = "Hello World!";

this.$el.html(

this.template({title: title})

);

}

});

});

The primary difference between Listings 4-20 and 4-22 is removal of the template from HTML. This brings two benefits, the first being that we reduce the problem of managing which templates to include within the HTML. This is a problem for complex applications that have many templates and many pages for which templates are needed for every page. Removing the templates from the HTML also reduces the payload of the initial page load, which is great for load-time performance. The templates are compiled into the JavaScript application code and compressed in production, which further improves performance. The second benefit is the separation that occurs by having each individual template in a separate file. This leads to easier maintainence, as you can focus on a particular template without worrying about affecting other templates. Listing 4-23 shows a sample template.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.