Skip to content
Browse files

using templating (ejs) to build different versions

  • Loading branch information...
1 parent c373153 commit 1a77e1577dfb58542e808ca9e4d31c4611f411f7 @refractalize committed Apr 11, 2011
Showing with 48 additions and 6 deletions.
  1. +3 −0 .gitignore
  2. +10 −0 Makefile
  3. +24 −0 make.js
  4. +2 −6 zo.js → zo-function.js
  5. +3 −0 zo-require.ejs
  6. +1 −0 zo-web.ejs
  7. +5 −0 zo.ejs
View
3 .gitignore
@@ -1 +1,4 @@
.*.swp
+zo-require.js
+zo-web.js
+zo.js
View
10 Makefile
@@ -0,0 +1,10 @@
+all : zo.js zo-web.js zo-require.js
+
+zo.js : zo-function.js zo.ejs
+ node make.js zo.ejs
+
+zo-web.js : zo-function.js zo-web.ejs
+ node make.js zo-web.ejs
+
+zo-require.js : zo-function.js zo-require.ejs
+ node make.js zo-require.ejs
View
24 make.js
@@ -0,0 +1,24 @@
+var ejs = require('ejs');
+var fs = require('fs');
+var _ = require('underscore');
+
+fs.readFile('zo-function.js', 'utf-8', function (err, zo) {
+ var ejsFile = process.argv[2];
+
+ fs.readFile(ejsFile, 'utf-8', function (err, template) {
+ if (err) {
+ console.log(err.message);
+ process.exit(1);
+ }
+ var output = ejs.render(template, {locals: {zo: zo}});
+
+ var jsFile = ejsFile.replace(/\.ejs$/, '.js');
+
+ fs.writeFile(jsFile, output, function (err) {
+ if (err) {
+ console.log(err.message);
+ process.exit(1);
+ }
+ });
+ })
+});
View
8 zo.js → zo-function.js
@@ -1,6 +1,4 @@
-var _ = require('underscore');
-
-var zo = function (items, pipeline) {
+function (items, pipeline) {
pipeline = (pipeline || []);
var runPipeline = function (items, funcs) {
@@ -104,6 +102,4 @@ var zo = function (items, pipeline) {
});
},
};
-};
-
-exports.zo = zo;
+};
View
3 zo-require.ejs
@@ -0,0 +1,3 @@
+define(['underscore'], function () {
+return <%= zo %>
+});
View
1 zo-web.ejs
@@ -0,0 +1 @@
+zo = <%= zo %>
View
5 zo.ejs
@@ -0,0 +1,5 @@
+var _ = require('underscore');
+
+var zo = <%= zo %>
+
+exports.zo = zo;

0 comments on commit 1a77e15

Please sign in to comment.
Something went wrong with that request. Please try again.