Take the 2-minute tour ×

Hi. I am trying to call dust template from a backbone view in rails project.

This is the way of calling JST template:

Spa.Views.PostsIndex = Backbone.View.extend({

template: JST['posts/index'],

I need to replace erb with dust. I am using dust_assets gem to render dust templates.

I have a file index.jst.dust template under app/assets/templates/post.

When I call the template from application.js file like below, I am able to render the dust template, but I am not able to render it from backbone view.

$(function() {

 JST["templates/index"]({ name : "World" }, function(err, out) {

Please suggest me how to call the dust template or point me to some link which explains the same.

share|improve this question
I took this approach, and it worked great: stackoverflow.com/questions/12758506/… –  granmoe Nov 16 at 1:34

1 Answer 1

up vote 0 down vote accepted

backbone.js's View class has a no-op render method - this means you have to override this method to tell the View class how to render it's view.

you will have to do this even though you've defined the template variable in the class.

an example would be:

render: function() {
  this.template({name: "World"}, function(err, out){
  return this;
share|improve this answer

Your Answer


