diff --git a/Cakefile b/Cakefile
index 0ad3b40..995a3a7 100644
--- a/Cakefile
+++ b/Cakefile
@@ -6,18 +6,18 @@ stitch = require 'stitch'
task 'build', 'build the whole jam', (cb) ->
console.log "Building"
files = fs.readdirSync 'src'
- files = ('src/' + file for file in files when file.match(/\.iced$/))
+ files = ('src/' + file for file in files when file.match(/\.coffee$/))
clearLibJs ->
buildParser ->
- runIced ['-I', 'inline', '-c', '-o', 'lib/'].concat(files), ->
- runIced ['-I', 'none', '-c', 'index.iced'], ->
- runIced ['package.iced'], ->
+ runCoffee ['-c', '-o', 'lib/'].concat(files), ->
+ runCoffee ['-c', 'index.coffee'], ->
+ runCoffee ['package.coffee'], ->
stitchIt ->
console.log "Done building."
cb() if typeof cb is 'function'
-runIced = (args, cb) ->
- proc = spawn 'iced', args
+runCoffee = (args, cb) ->
+ proc = spawn 'coffee', args
console.log args
proc.stderr.on 'data', (buffer) -> console.log buffer.toString()
proc.on 'exit', (status) ->
diff --git a/README.md b/README.md
index 47dd6ba..b6f4bbb 100644
--- a/README.md
+++ b/README.md
@@ -216,8 +216,22 @@ app.register '.toffee', toffee
contributing
=============
-I would love for someone to make a textmate/sublime bundle for Toffee. :-) . I would even pay for it.
+I'm likely to accept good pull requests.
+If you'd like to edit code for this project, note that you should always edit the `.coffee` files,
+as the `.js` files as generated automatically by building.
+
+To build
+```
+> cake build
+```
+
+To make sure you didn't break something
+```
+> coffee tests/run_cases.coffee
+```
+
+I'm also very interested in someone building a Sublime/Textmate package for Toffee.
todo
======
diff --git a/index.iced b/index.coffee
similarity index 100%
rename from index.iced
rename to index.coffee
diff --git a/index.js b/index.js
index f97d022..2ca83d9 100644
--- a/index.js
+++ b/index.js
@@ -1,4 +1,4 @@
-// Generated by IcedCoffeeScript 1.3.3b
+// Generated by CoffeeScript 1.3.3
(function() {
var e, eclass;
diff --git a/lib/command_line.js b/lib/command_line.js
index a9a52ca..5d994a7 100644
--- a/lib/command_line.js
+++ b/lib/command_line.js
@@ -1,4 +1,4 @@
-// Generated by IcedCoffeeScript 1.3.3b
+// Generated by CoffeeScript 1.3.3
(function() {
var engine, fs, getVersionNumber, printUsage, view;
@@ -23,7 +23,9 @@
args = process.argv.slice(2);
if (args.length === 2) {
coffee = true;
- if (args[0] !== "-c") printUsage();
+ if (args[0] !== "-c") {
+ printUsage();
+ }
} else if (args.length !== 1) {
printUsage();
}
diff --git a/lib/consts.js b/lib/consts.js
index 790314c..beb7441 100644
--- a/lib/consts.js
+++ b/lib/consts.js
@@ -1,4 +1,4 @@
-// Generated by IcedCoffeeScript 1.3.3b
+// Generated by CoffeeScript 1.3.3
(function() {
exports.states = {
diff --git a/lib/engine.js b/lib/engine.js
index dc06c33..82484be 100644
--- a/lib/engine.js
+++ b/lib/engine.js
@@ -1,4 +1,4 @@
-// Generated by IcedCoffeeScript 1.3.3b
+// Generated by CoffeeScript 1.3.3
(function() {
var engine, fs, path, states, util, view,
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
@@ -52,7 +52,9 @@
}
realpath = filename;
pwd = path.dirname(realpath);
- if (Date.now() - this.lastCacheReset > this.maxCacheAge) this._resetCache();
+ if (Date.now() - this.lastCacheReset > this.maxCacheAge) {
+ this._resetCache();
+ }
v = this.viewCache[filename] || this._loadAndCache(filename, options);
if (v) {
options.__parent = filename;
@@ -83,7 +85,9 @@
options.__parent = parent_realpath;
for (k in parent_options) {
v = parent_options[k];
- if ((k.slice(0, 2) !== "__") && !(local_keys[k] != null)) options[k] = v;
+ if ((k.slice(0, 2) !== "__") && !(local_keys[k] != null)) {
+ options[k] = v;
+ }
}
_ref = this.runSync(filename, options), err = _ref[0], res = _ref[1];
if (err) {
@@ -117,7 +121,9 @@
txt = fs.readFileSync(filename, 'utf-8');
} catch (e) {
txt = "Error: Could not read " + filename;
- if (options.__parent != null) txt += " requested in " + options.__parent;
+ if (options.__parent != null) {
+ txt += " requested in " + options.__parent;
+ }
}
v = new view(txt, {
fileName: filename
diff --git a/lib/view.js b/lib/view.js
index d40f49b..d69442d 100644
--- a/lib/view.js
+++ b/lib/view.js
@@ -1,4 +1,4 @@
-// Generated by IcedCoffeeScript 1.3.3b
+// Generated by CoffeeScript 1.3.3
(function() {
var TAB_SPACES, coffee, parser, states, view, vm;
@@ -109,7 +109,9 @@
res += "\n
";
txt_lines = this.txt.split('\n');
for (i = _i = _ref = this.error.toffee_line_range[0] - 3, _ref1 = this.error.toffee_line_range[1] + 1; _ref <= _ref1 ? _i < _ref1 : _i > _ref1; i = _ref <= _ref1 ? ++_i : --_i) {
- if ((i < 0) || i > txt_lines.length - 1) continue;
+ if ((i < 0) || i > txt_lines.length - 1) {
+ continue;
+ }
line = this._ppEscape(txt_lines[i]);
lineno = i + 1;
res += "\n" + lineno + ": " + line + "
";
@@ -137,7 +139,9 @@
converted_msg: msg
};
search = msg.match(/on line ([0-9]+)/);
- if (!((search != null ? search.length : void 0) >= 2)) return res;
+ if (!((search != null ? search.length : void 0) >= 2)) {
+ return res;
+ }
res.src_line = parseInt(search[1]);
res.toffee_line_range = [res.src_line, res.src_line];
if (this.fileName) {
@@ -165,7 +169,9 @@
converted_msg: msg
};
search = stack.match(/([0-9]+):[0-9]+/);
- if (!((search != null ? search.length : void 0) >= 2)) return res;
+ if (!((search != null ? search.length : void 0) >= 2)) {
+ return res;
+ }
res.src_line = search[1];
src_lines = src.split('\n');
txt_lines = this.txt.split('\n');
@@ -222,7 +228,9 @@
converted_msg: msg
};
search = msg.match(/on line ([0-9]+)/);
- if (!((search != null ? search.length : void 0) >= 2)) return res;
+ if (!((search != null ? search.length : void 0) >= 2)) {
+ return res;
+ }
res.src_line = search[1];
src_lines = src.split('\n');
txt_lines = this.txt.split('\n');
@@ -375,7 +383,9 @@
obj = obj_arr[_i];
if (obj[0] === "COFFEE") {
ib = this._getIndentationBaseline(obj[1]);
- if (ib != null) return ib;
+ if (ib != null) {
+ return ib;
+ }
}
}
return 0;
@@ -406,7 +416,9 @@
*/
var lines, res, y, y_l;
- if (!(baseline != null)) baseline = this._getIndentationBaseline(coffee);
+ if (!(baseline != null)) {
+ baseline = this._getIndentationBaseline(coffee);
+ }
if (!(baseline != null)) {
res = 0;
} else {
@@ -431,7 +443,9 @@
while (lines.length && lines[0].match(/^[ ]*$/)) {
lines = lines.slice(1);
}
- if (!lines.length) return '';
+ if (!lines.length) {
+ return '';
+ }
rxx = /^[ ]*/;
strip = indent_baseline;
indent = this._space(indent_level);
diff --git a/package.iced b/package.coffee
similarity index 66%
rename from package.iced
rename to package.coffee
index a48bbdc..334fcc8 100644
--- a/package.iced
+++ b/package.coffee
@@ -3,7 +3,7 @@ fs = require 'fs'
obj =
name: "toffee"
description: """an express 3.x templating language based on coffeescript with slicker tokens."""
- version: "0.0.7"
+ version: "0.0.9"
directories: {"lib" : "./lib"}
main: "index.js"
author: "Chris Coyne
"
@@ -13,13 +13,12 @@ obj =
repository:
type: "git"
url: "http://github.com/malgorithms/toffee"
- devDependencies:
- "iced-coffee-script" : "1.3.1a"
licenses: [
{
type: "MIT"
- url: "http://github.com/malgorithms/node-toffee/raw/master/LICENSE"
+ url: "http://github.com/malgorithms/toffee/raw/master/LICENSE"
}
]
-await fs.writeFile './package.json', JSON.stringify(obj, null, " "), defer err, res
\ No newline at end of file
+fs.writeFile './package.json', JSON.stringify(obj, null, " "), (err, res) ->
+ console.log "package.json written."
\ No newline at end of file
diff --git a/package.json b/package.json
index c79e93f..8b6ff39 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
{
"name": "toffee",
"description": "an express 3.x templating language based on coffeescript with slicker tokens.",
- "version": "0.0.7",
+ "version": "0.0.8",
"directories": {
"lib": "./lib"
},
@@ -15,13 +15,10 @@
"type": "git",
"url": "http://github.com/malgorithms/toffee"
},
- "devDependencies": {
- "iced-coffee-script": "1.3.1a"
- },
"licenses": [
{
"type": "MIT",
- "url": "http://github.com/malgorithms/node-toffee/raw/master/LICENSE"
+ "url": "http://github.com/malgorithms/toffee/raw/master/LICENSE"
}
]
}
\ No newline at end of file
diff --git a/src/command_line.iced b/src/command_line.coffee
similarity index 100%
rename from src/command_line.iced
rename to src/command_line.coffee
diff --git a/src/consts.iced b/src/consts.coffee
similarity index 100%
rename from src/consts.iced
rename to src/consts.coffee
diff --git a/src/engine.iced b/src/engine.coffee
similarity index 100%
rename from src/engine.iced
rename to src/engine.coffee
diff --git a/src/view.iced b/src/view.coffee
similarity index 100%
rename from src/view.iced
rename to src/view.coffee
diff --git a/test/run_cases.coffee b/test/run_cases.coffee
new file mode 100644
index 0000000..1557a02
--- /dev/null
+++ b/test/run_cases.coffee
@@ -0,0 +1,56 @@
+{engine} = require '../lib/engine'
+fs = require 'fs'
+path = require 'path'
+
+e = new engine(maxCacheAge: 10000)
+
+run_case_dir = (dir, cb) ->
+ expected = fs.readFileSync "#{dir}/output.toffee", "utf8"
+ if path.existsSync "#{dir}/vars.json"
+ vars = fs.readFileSync "#{dir}/vars.json", "utf8"
+ vars = JSON.parse vars
+ else
+ vars = {}
+ d = Date.now()
+ e.run "#{dir}/input.toffee", vars, (err, res) ->
+ time_ms = Date.now() - d
+ if err
+ cb err, time_ms
+ else
+ if res isnt expected
+ cb "Failure in case #{dir}." +
+ "\n\nExpected\n=====\n#{expected}\n=====" +
+ "\nGot\n=====\n#{res}\n=====\n", time_ms
+ else
+ cb null, time_ms
+
+run_all_case_dirs = (cb) ->
+ time_ms = 0
+ case_dirs = fs.readdirSync "#{__dirname}/cases/"
+ countdown = case_dirs.length
+ for dir in case_dirs
+ run_case_dir "#{__dirname}/cases/#{dir}", (err, ms) ->
+ countdown--
+ time_ms += ms
+ if err
+ console.log err
+ process.exit 1
+ if countdown is 0
+ cb null, time_ms, case_dirs.length
+
+run_all_case_dirs (err, time, tests_run) ->
+
+ console.log "SUCCESS for #{tests_run} cold tests in #{time}ms"
+
+ times = []
+ speed_runs = 20
+ countdown = speed_runs
+ total_time = 0
+ total_tests = 0
+ for i in [0...speed_runs]
+ run_all_case_dirs (err, time, tests_run) ->
+ countdown--
+ total_time += time
+ total_tests += tests_run
+ if countdown is 0
+ console.log "SUCCESS for #{total_tests} hot tests in #{total_time}ms. #{total_time / total_tests}ms/test"
\ No newline at end of file
diff --git a/test/run_cases.iced b/test/run_cases.iced
deleted file mode 100644
index 4023ec3..0000000
--- a/test/run_cases.iced
+++ /dev/null
@@ -1,49 +0,0 @@
-{engine} = require '../lib/engine'
-fs = require 'fs'
-path = require 'path'
-
-e = new engine(maxCacheAge: 10000)
-
-run_case_dir = (dir, cb) ->
- expected = fs.readFileSync "#{dir}/output.toffee", "utf8"
- if path.existsSync "#{dir}/vars.json"
- vars = fs.readFileSync "#{dir}/vars.json", "utf8"
- vars = JSON.parse vars
- else
- vars = {}
- d = Date.now()
- await e.run "#{dir}/input.toffee", vars, defer err, res
- time_ms = Date.now() - d
- if err
- cb err, time_ms
- else
- if res isnt expected
- cb "Failure in case #{dir}." +
- "\n\nExpected\n=====\n#{expected}\n=====" +
- "\nGot\n=====\n#{res}\n=====\n", time_ms
- else
- cb null, time_ms
-
-run_all_case_dirs = (cb) ->
- time_ms = 0
- case_dirs = fs.readdirSync "#{__dirname}/cases/"
- for dir in case_dirs
- await run_case_dir "#{__dirname}/cases/#{dir}", defer err, ms
- time_ms += ms
- if err
- console.log err
- process.exit 1
- cb null, time_ms, case_dirs.length
-
-await run_all_case_dirs defer err, time, tests_run
-
-console.log "SUCCESS for #{tests_run} cold tests in #{time}ms"
-
-times = []
-speed_runs = 20
-for i in [0...speed_runs]
- await run_all_case_dirs defer err, times[i], tests_run
-total_time = 0
-total_time += t for t in times
-total_tests = tests_run * speed_runs
-console.log "SUCCESS for #{total_tests} hot tests in #{total_time}ms. #{total_time / total_tests}ms/test"
\ No newline at end of file
diff --git a/toffee.js b/toffee.js
index 94e33ad..cdd4c0a 100644
--- a/toffee.js
+++ b/toffee.js
@@ -48,7 +48,7 @@
};
}
return this.require.define;
-}).call(this)({"command_line": function(exports, require, module) {// Generated by IcedCoffeeScript 1.3.3b
+}).call(this)({"command_line": function(exports, require, module) {// Generated by CoffeeScript 1.3.3
(function() {
var engine, fs, getVersionNumber, printUsage, view;
@@ -73,7 +73,9 @@
args = process.argv.slice(2);
if (args.length === 2) {
coffee = true;
- if (args[0] !== "-c") printUsage();
+ if (args[0] !== "-c") {
+ printUsage();
+ }
} else if (args.length !== 1) {
printUsage();
}
@@ -90,7 +92,7 @@
};
}).call(this);
-}, "consts": function(exports, require, module) {// Generated by IcedCoffeeScript 1.3.3b
+}, "consts": function(exports, require, module) {// Generated by CoffeeScript 1.3.3
(function() {
exports.states = {
@@ -99,7 +101,7 @@
};
}).call(this);
-}, "engine": function(exports, require, module) {// Generated by IcedCoffeeScript 1.3.3b
+}, "engine": function(exports, require, module) {// Generated by CoffeeScript 1.3.3
(function() {
var engine, fs, path, states, util, view,
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
@@ -153,7 +155,9 @@
}
realpath = filename;
pwd = path.dirname(realpath);
- if (Date.now() - this.lastCacheReset > this.maxCacheAge) this._resetCache();
+ if (Date.now() - this.lastCacheReset > this.maxCacheAge) {
+ this._resetCache();
+ }
v = this.viewCache[filename] || this._loadAndCache(filename, options);
if (v) {
options.__parent = filename;
@@ -184,7 +188,9 @@
options.__parent = parent_realpath;
for (k in parent_options) {
v = parent_options[k];
- if ((k.slice(0, 2) !== "__") && !(local_keys[k] != null)) options[k] = v;
+ if ((k.slice(0, 2) !== "__") && !(local_keys[k] != null)) {
+ options[k] = v;
+ }
}
_ref = this.runSync(filename, options), err = _ref[0], res = _ref[1];
if (err) {
@@ -218,7 +224,9 @@
txt = fs.readFileSync(filename, 'utf-8');
} catch (e) {
txt = "Error: Could not read " + filename;
- if (options.__parent != null) txt += " requested in " + options.__parent;
+ if (options.__parent != null) {
+ txt += " requested in " + options.__parent;
+ }
}
v = new view(txt, {
fileName: filename
@@ -660,7 +668,7 @@ exports.main = function commonjsMain(args) {
if (typeof module !== 'undefined' && require.main === module) {
exports.main(typeof process !== 'undefined' ? process.argv.slice(1) : require("system").args);
}
-}}, "view": function(exports, require, module) {// Generated by IcedCoffeeScript 1.3.3b
+}}, "view": function(exports, require, module) {// Generated by CoffeeScript 1.3.3
(function() {
var TAB_SPACES, coffee, parser, states, view, vm;
@@ -771,7 +779,9 @@ if (typeof module !== 'undefined' && require.main === module) {
res += "\n";
txt_lines = this.txt.split('\n');
for (i = _i = _ref = this.error.toffee_line_range[0] - 3, _ref1 = this.error.toffee_line_range[1] + 1; _ref <= _ref1 ? _i < _ref1 : _i > _ref1; i = _ref <= _ref1 ? ++_i : --_i) {
- if ((i < 0) || i > txt_lines.length - 1) continue;
+ if ((i < 0) || i > txt_lines.length - 1) {
+ continue;
+ }
line = this._ppEscape(txt_lines[i]);
lineno = i + 1;
res += "\n" + lineno + ": " + line + "
";
@@ -799,7 +809,9 @@ if (typeof module !== 'undefined' && require.main === module) {
converted_msg: msg
};
search = msg.match(/on line ([0-9]+)/);
- if (!((search != null ? search.length : void 0) >= 2)) return res;
+ if (!((search != null ? search.length : void 0) >= 2)) {
+ return res;
+ }
res.src_line = parseInt(search[1]);
res.toffee_line_range = [res.src_line, res.src_line];
if (this.fileName) {
@@ -827,7 +839,9 @@ if (typeof module !== 'undefined' && require.main === module) {
converted_msg: msg
};
search = stack.match(/([0-9]+):[0-9]+/);
- if (!((search != null ? search.length : void 0) >= 2)) return res;
+ if (!((search != null ? search.length : void 0) >= 2)) {
+ return res;
+ }
res.src_line = search[1];
src_lines = src.split('\n');
txt_lines = this.txt.split('\n');
@@ -884,7 +898,9 @@ if (typeof module !== 'undefined' && require.main === module) {
converted_msg: msg
};
search = msg.match(/on line ([0-9]+)/);
- if (!((search != null ? search.length : void 0) >= 2)) return res;
+ if (!((search != null ? search.length : void 0) >= 2)) {
+ return res;
+ }
res.src_line = search[1];
src_lines = src.split('\n');
txt_lines = this.txt.split('\n');
@@ -1037,7 +1053,9 @@ if (typeof module !== 'undefined' && require.main === module) {
obj = obj_arr[_i];
if (obj[0] === "COFFEE") {
ib = this._getIndentationBaseline(obj[1]);
- if (ib != null) return ib;
+ if (ib != null) {
+ return ib;
+ }
}
}
return 0;
@@ -1068,7 +1086,9 @@ if (typeof module !== 'undefined' && require.main === module) {
*/
var lines, res, y, y_l;
- if (!(baseline != null)) baseline = this._getIndentationBaseline(coffee);
+ if (!(baseline != null)) {
+ baseline = this._getIndentationBaseline(coffee);
+ }
if (!(baseline != null)) {
res = 0;
} else {
@@ -1093,7 +1113,9 @@ if (typeof module !== 'undefined' && require.main === module) {
while (lines.length && lines[0].match(/^[ ]*$/)) {
lines = lines.slice(1);
}
- if (!lines.length) return '';
+ if (!lines.length) {
+ return '';
+ }
rxx = /^[ ]*/;
strip = indent_baseline;
indent = this._space(indent_level);