Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8586565

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T22:20:23+00:00 2026-06-11T22:20:23+00:00

Let me elaborate on my setup: I have precompiled dust.js templates that I would

  • 0

Let me elaborate on my setup:
I have precompiled dust.js templates that I would like to use with Backbone.LayoutManager.

Backbone.LayoutManager uses the following configuration:

Backbone.LayoutManager.configure
  manage: true
  fetch: (name) ->
    name

So the name of the template is passed through fetch straight to render, and I’d like to override render like this:

render: (template, context) ->
  done = @async
  dust.render @template, context, (err, out) ->
    throw err if err
    done(out)

But I cannot do this with render (presumably because the LayoutManager author assumed that template rendering would be synch).

Does anyone know how I could accomplish this?

  • 0 0 Answers
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T22:20:24+00:00Added an answer on June 11, 2026 at 10:20 pm

    You’ll need to modify the LayoutManger to handle asynchronous rendering of templates.

    One of the ways to do this is to use the jQuery Deferred object where the call to render returns an instance of a Deferred object, which you then resolve in the call to the Dust library.

    Then, modify Backbone.LayoutManager to NOT continue doing what it wants to with the templates until that Deferred object has been resolve.

    in render:

    render: (template, context) ->
        dfd = $.Deferred()
    
        dust.render @template, context, (err, out) ->
            throw err if err
            done(out)
            dfd.resolve()
    
        return dfd;
    

    You then take the method in Backbone.LayoutManager that calls render and instead of doing something with the return from render you attach that “something” to the done handler for the deferred you passed back.

        dfd = render(template, context)
        dfd.done(do_something_with_this_template);
    

    I’m using Marionette.js (along with it’s async variant) and dust, this is what my core render method looks like:

        render: function(){
            var dfd = $.Deferred();
    
            var template_context = this.model;
            if(_.isUndefined(template_context) || _.isFunction(template_context)){
                template_context = new (Backbone.Model.extend({}));
            }
    
            if(this.id) this.$el.attr('id', this.id);
    
            var that = this;
            dust.stream(this.tpl_name, template_context.toJSON())
                .on('data', function(data){
                    that.$el.html(data);
                })
                .on('end', function(){
                    dfd.resolve();
                    that.enable_menus();
                    that.trigger('template:rendered');
                })
                .on('error', function(err){
                    dfd.reject();
                    window.le(err.message, err);
                    that.trigger('template:error');
                });
    
            return dfd;
        }
    

    (Obviously not using coffeescript either…)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's have an example like below: package xliiv.sandbox; import android.app.Activity; import android.os.Bundle; import android.util.Log;
Let me explain best with an example. Say you have node class that can
Let's say that I have a SQLite database that I create in a separate
Let's say I have a sortable list like this: $(.song-list).sortable({ handle : '.pos_handle', axis
Let's say I have a string like this: var str = /abcd/efgh/ijkl/xxx-1/xxx-2; How do
Let's say I have a class like so: class Gerbil{ int id; float x,y,z;
Let me elaborate on the question... I have a custom CMS (built on codeigniter
Sorry if my question is uncleared. Let me elaborate. I have a rectangle of
maybe the title is not very clear, let me elaborate. I have a python
I hope that made sense, let me elaborate: There is a table of tracking

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.