How to set a Renderer in Marionette.js?

devquora
devquora

Posted On: Feb 22, 2018

 

Renderer in Marionette is used to render data into a template. It can be set by the View class by using the class method setRendered. It accepts two arguments. The first is the template that is passed to the view. The second is the data that is to be rendered into the template. This function returns a string that contains the result of applying data to the template.

Example

Marionette.View.setRenderer(function(template, data) {
  return _.template(template)(data);
});

var myView = new Marionette.View({
  template: 'Hello <%- name %>!',
  model: new Backbone.Model({ name: 'World' })
});
myView.render();
myView.el === '<div>Hello World!</div>';

    Related Questions

    Please Login or Register to leave a response.

    Related Questions

    Marionette js Interview Questions

    What is Marionette.js ?

    Marionette.js is a composite application library for the Backbone.js. It simplifies the construction of the large-scale JavaScript applications. It is nothing but a collection of the common design and...

    Marionette js Interview Questions

    List some features of Marionette.js ?

    Features of Marionette.jsIt is scalable as the applications built-in modules with event-driven architecture. It is easily modifiable. It works with the specific need of your application. It has ...

    Marionette js Interview Questions

    What is current stable version of Marionette.js ?

    v4.1.2 is the current stable version of MarionetteJS....