Tuesday 15 March 2011

backbone.js - Marionette view's Handlebars template compiled once before use -


I am using Toggle Handlebar with Marianette. The composite view template is defined as:

  template: function (serialized data) {var templFn = Handlebars.compile (myTemplateDef); This return.templFn (serialized data); }   

In Traditional Backbone with Handlebar, it is suggested that each time we present the scene, it is suggested not to compile the template, but the compiled template is given Instead of storing it in the form it is compiled only once. Reservations on resources:

  templFn: Handlebars.compile (myTemplateDef), render: function () {var serializedData = this.model.toJSON (); ... this. $ El.append (this.templFn (serializedData);}   

But the context of the template in the merriet case is window and I do not control how / When the template is called.

So the question is: Given that we do not want to create a global conflict window.templFn in the case of a marinenet, One way to separate from using?

Merriet is a handler plugin:

It completely Not at all, but you should at least be able to see how they are controlling the collection of templates.

In general, the Merient is a Mirianet Renderer And Merineet template cache allows the object to be compiled once, and only once, and that cached template is sung again with compilation.

No comments:

Post a Comment