Permalink
Browse files

switch ejs for hogan.js

  • Loading branch information...
1 parent e0f3218 commit e7db7526a20d136b6e7de0a6fa20048e5882e5cc @fat fat committed Apr 8, 2012
View
@@ -40,7 +40,7 @@ var async = require('async')
// 'Packages:' is optional because it's not in <= 0.8.x Ender builds
, buildInfoRegex = /\n {2}\* Build: ender ([^\n]*)\s\S*(?:(?: {2}\* Packages: )([^\n]*))?/
- , templateFile = '../resources/build.ejs'
+ , templateFile = '../resources/build.mustache'
, SourceBuild = {
init: function (options) {
@@ -39,8 +39,8 @@ var fs = require('fs')
, FilesystemError = require('./errors').FilesystemError
, templateFiles = {
- 'standard' : '../resources/source-package.ejs'
- , 'ender-js' : '../resources/ender-js-package.ejs' // a special template for the root package
+ 'standard' : '../resources/source-package.mustache'
+ , 'ender-js' : '../resources/ender-js-package.mustache' // a special template for the root package
}
// pass the source through
View
@@ -32,31 +32,23 @@
*/
var fs = require('fs')
- , ejs = require('ejs')
, path = require('path')
, async = require('async')
+ , hogan = require('hogan.js')
, FilesystemError = require('./errors').FilesystemError
// async.memoize lets us read each file once only, no matter how many calls before & after the file is read
, readTemplate = async.memoize(function (file, callback) {
fs.readFile(path.resolve(__dirname, file), 'utf-8', function (err, templateContents) {
if (err) return callback(new FilesystemError(err))
-
- // this bit of fluff does some simple reformatting of our text so we can write our templates
- // a bit nicer and not cram them up so much.
- templateContents = templateContents
- .replace(/^[\t ]+<%/gm, '<%')
- .replace(/\s*\\\n/g, '')
- .replace(/(^<%[^%]+%>)\n/gm, '$1')
-
callback(null, templateContents)
})
})
, generateSource = function (file, data, callback) {
readTemplate(file, function (err, templateContents) {
if (err) return callback(err) // wrapped above
- callback(null, ejs.render(templateContents, data))
+ callback(null, hogan.compile(templateContents).render(data))
})
}
View
@@ -18,7 +18,7 @@
, "colors": ">= 0.3.0"
, "uglify-js": ">= 0.0.1"
, "async": ">= 0.1.9"
- , "ejs": ">= 0.6.1"
+ , "hogan.js": ">= 2.0.0"
, "archy": ">= 0.0.2"
, "colors-tmpl": ">= 0.0.2"
, "xregexp": ">= 1.5.3"
@@ -1,18 +1,13 @@
/*!
* =============================================================
* Ender: open module JavaScript framework (https://ender.no.de)
- * Build: ender <%- context %>
- * Packages: <%- packages %>
+ * Build: ender {{{context}}}
+ * Packages: {{packages}}
* =============================================================
*/
-<% if (sandbox) { %>
-!function () {
-<% } %>
+{{#sandbox}}!function () {
-<%- source %>
-<% if (sandbox) { %>
+{{/sandbox}}{{{source}}}{{#sandbox}}
-
-}.call({}); \
-<% } %> \
+}.call({});{{/sandbox}}
@@ -1,14 +0,0 @@
-<% if (options.sandbox) { %>
-/* Declare local API */
-var require, provide, $, ender;
-
-<%- mainSource.raw() %>
-
-
-/* Set Local API */
-require = this.require
-provide = this.provide
-ender = $ = this.ender \
-<% } else { %> \
-<%- mainSource.raw() %> \
-<% } %> \
@@ -0,0 +1,10 @@
+{{#options.sandbox}}
+/* Declare local API */
+var require, provide, $, ender;
+
+{{/options.sandbox}}{{{mainSource.raw}}}{{#options.sandbox}}
+
+/* Set Local API */
+require = this.require
+provide = this.provide
+ender = $ = this.ender{{/options.sandbox}}
@@ -1,25 +0,0 @@
-<% if (!options.noop) { %> \
-!function () {
-
- var module = { exports: {} }, exports = module.exports;
- <% if (mainSource) { %>
-
- <%- mainSource.indented() %>
- <% } %>
-
- provide("<%- packageName %>", module.exports);
- <% if (options.sandbox) { %>
-
- window["<%- packageName %>"] = module.exports;
- <% } %>
- <% if (enderSource) { %>
-
- <%- enderSource.indented() %>
-
- <% } else { %>
- $.ender(module.exports);
- <% } %>
-}(); \
-<% } else { %> \
- <%- mainSource.raw() %> \
-<% } %> \
@@ -0,0 +1,19 @@
+{{^options.noop}}
+!function () {
+
+ var module = { exports: {} }, exports = module.exports;
+{{#mainSource}}
+
+{{{indented}}}{{/mainSource}}
+ provide("{{packageName}}", module.exports);
+{{#options.sandbox}}
+
+ window["{{packageName}}"] = module.exports;
+{{/options.sandbox}}{{#enderSource}}
+
+{{{indented}}}
+{{/enderSource}}
+{{^enderSource}}
+ $.ender(module.exports);
+{{/enderSource}}
+}();{{/options.noop}}{{#options.noop}}{{{mainSource.raw}}}{{/options.noop}}
@@ -31,8 +31,8 @@ var testCase = require('buster').testCase
, FilesystemError = require('../../lib/errors').FilesystemError
, templateFiles = {
- 'standard': __dirname + '/../../resources/source-package.ejs'
- , 'ender-js': __dirname + '/../../resources/ender-js-package.ejs'
+ 'standard': __dirname + '/../../resources/source-package.mustache'
+ , 'ender-js': __dirname + '/../../resources/ender-js-package.mustache'
}
, templateFileContents

0 comments on commit e7db752

Please sign in to comment.