Permalink
Browse files

Added "node" compatibility

  • Loading branch information...
1 parent c3943c5 commit cf0d49bda0d18ac807a26a504cec54189be4f006 @shinuza shinuza committed Nov 5, 2011
Showing with 7 additions and 7 deletions.
  1. +7 −7 microtemplatez.js
View
@@ -3,9 +3,9 @@
* Copyright: Addy Osmani, 2011.
* Licensed under a dual-MIT/GPL license
*/
-;( function ( window, doc, undef ) {
+;( function ( root ) {
- templatez = function( tmpl, data ) {
+ var templatez = function( tmpl, data ) {
return tmpl.replace((RegExp("{{\\s*([a-z0-9_][\\.a-z0-9_]*)\\s*}}", "gi")), function (tag, k) {
var p = k.split("."),
len = p.length,
@@ -18,13 +18,13 @@
});
};
- getTemplatez = function(){
- return templatez;
+ if (typeof exports !== 'undefined') {
+ root = exports;
+ } else {
+ root.templatez = templatez;
}
- window.templatez = getTemplatez();
-
-} )( this, this.document );
+} )( this );

6 comments on commit cf0d49b

root.templatez is not defined if exports exist, right?

Contributor

shinuza replied Nov 7, 2011

Right, could this be an issue?

Owner

addyosmani replied Nov 7, 2011

@shinuza It could be. We might need to back this out until we can figure out a better solution.

Contributor

shinuza replied Nov 7, 2011

This bit was inspired by underscore/backbone. You might want to check it out, there's also work to make it compatible with AMD, it depends how far you want to take it.

http://documentcloud.github.com/underscore/docs/underscore.html

Owner

addyosmani replied Nov 7, 2011

Contributor

shinuza replied Nov 8, 2011

So that would be :

-Simple version
-Minified version
-AMD/CommonJS Modules

Sounds good to me, now you may want to have a build system to create these on the fly.

Please sign in to comment.