Search code examples
javascriptrequirejsdust.js

Using Dust in require.js


Sorry for posting another "how do you use * with require.js" question, but I can't seem to get dust.js working in my require project. I've googled around and other people are definitely getting dust to work with require. My configuration is fairly standard, but I can't find anyone having the same problems as I'm seeing.

I'm using the version of dust 0.3.0 from here: https://github.com/akdubya/dustjs/blob/master/dist/dust-core-0.3.0.js

here is my config:

requirejs.config({
//exceptions:
paths: {
    'jquery' : 'lib/require-jquery.1.9.1',
    'jquery.mockjax' : 'lib/jquery.mockjax.1.5.1',
    'dust' : 'lib/dust.0.3.0'

},
//Shims are required for jQuery plugins.
shim: {
     'jquery.mockjax': {
     deps: ['jquery'],
     exports: 'jQuery.fn.mockjax'
     },
     'dust': {
     exports: 'dust'
     }
}

});

this is how I include dust in my module:

define( function( require ) {
   var _d = require('dust')
   , _template1 = require('text!template/basicmodal.html');


   function render(key,callback){

            var compiled = _d.compile("Hello {name}!", key);
            _d.loadSource(compiled);
            _d.render(key, {name: "Fred"}, callback);

   }

   return {
   render : render,

If I set a breakpoint within the render function I can see that _d does contain the dust object, but for some reason it doesn't have all its methods. In particular its 'compile' method is missing which causes my code to fail.

Does anyone with a better understanding of dust know what I might be missing here?


Solution

  • Please see if using https://github.com/akdubya/dustjs/blob/master/dist/dust-full-0.3.0.js instead helps you.