Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 781
underscorePez Avatar asked Apr 24 '26 16:04

underscorePez


1 Answers

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

like image 143
Ian Lim Avatar answered Apr 27 '26 06:04

Ian Lim



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!