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

jsmart should support AMD and CMD #10

Closed
snadn opened this issue Feb 10, 2015 · 5 comments
Closed

jsmart should support AMD and CMD #10

snadn opened this issue Feb 10, 2015 · 5 comments

Comments

@snadn
Copy link

snadn commented Feb 10, 2015

how can i use jsmart when there is not module.exports = jSmart; in jsmart.js.
and i dont think set fetch in String.prototype is a good way.

@umakantp
Copy link
Owner

Go ahead require jsmart js and use jSmart directly in all common js environments and browsers. You do not have to necessarily use String.prototype.fetch
e.g.
require('jsmart');
var compiledTpl = new jSmart('Hello {$name}');
console.log(compiledTpl.fetch({name: 'World'}));

@snadn
Copy link
Author

snadn commented Feb 10, 2015

oh, i know! I use like this var jSmart = require('jsmart');, so jSmart not that i expect.
use jsmart without defined is very very ...
I think shoud use like this

(function () {
    var _jSmart;

    ...

    if ( typeof module === "object" && module && typeof module.exports === "object" ) {
        module.exports = _jSmart;
    } else {
        global.jSmart = _jSmart;

        if ( typeof define === "function" && define.amd ) {
            define( "jSmart", [], function () { return _jSmart; } );
        }
    }

})();

@umakantp
Copy link
Owner

Okay, I get you. I'll get this plugged in the next release. Thanks

@StanZap
Copy link

StanZap commented Feb 11, 2015

Excellent.

@umakantp
Copy link
Owner

Done in a42cec7

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

No branches or pull requests

3 participants