Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dust supports native AMD and CJS compilation #31

Open
sethkinast opened this issue Apr 30, 2015 · 1 comment
Open

Dust supports native AMD and CJS compilation #31

sethkinast opened this issue Apr 30, 2015 · 1 comment

Comments

@sethkinast
Copy link

Hi,

Thanks for using Dust!

> dust.compile("Hello {world}")
'(function(dust){function body_0(chk,ctx){return chk.w("Hello ").f(ctx.get(["world"], false),ctx,"h");}body_0.__dustBody=!0;return body_0}(dust));'
> dust.config.amd = true;
true
> dust.compile("Hello {world}")
'define(["dust.core"],function(dust){function body_0(chk,ctx){return chk.w("Hello ").f(ctx.get(["world"], false),ctx,"h");}body_0.__dustBody=!0;return body_0});'
> dust.config.amd = false; dust.config.cjs = true;
true
> dust.compile("Hello {world}")
'module.exports=function(dust){var tmpl=(function(dust){function body_0(chk,ctx){return chk.w("Hello ").f(ctx.get(["world"], false),ctx,"h");}body_0.__dustBody=!0;return body_0}(dust));var f=function load(ctx, cb) {\n      var fn = cb ? \'render\' : \'stream\';\n      return dust[fn](tmpl, ctx, cb);\n    };f.template=tmpl;return f}'

You may find it useful to delegate to Dust's native compiler to reduce your work.

(AMD support: Dust >= 2.6)
(CJS support: Dust >= 2.7)

@vladtsf
Copy link
Owner

vladtsf commented May 5, 2015

Hi, @sethkinast!
I really appreciate your letting me know. I'll integrate with the new API very soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants