Skip to content

Loading Dust via AMD (require.js)

Seth Kinast edited this page Jan 26, 2015 · 9 revisions

Dust supports being loaded as an AMD module as of Dust 2.5.2.

To maintain backwards compatibility, you must enable a config flag to tell Dust to register itself as a named AMD module (in the same way jQuery works)

define.amd.dust = true;

After you've done this, you can use the module names dust or dust-core to load Dust, and dust-full to load Dust plus the compiler.

<script src="r.js"></script>
<script type="text/javascript">
    define.amd.dust = true;
    require(["dust-full"], function(dust) {
        dust.render(...);
    });
</script>