-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added compile to js option to CLI. Closes #58.
- Loading branch information
1 parent
a8f3a93
commit b409d7d
Showing
12 changed files
with
488 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/usr/bin/env sh | ||
coffeekup --js template.coffee | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,223 @@ | ||
function template(data) {var a,i,li,p,s,th,u,ul;a = function(){return __ck.tag('a', arguments);};i = function(){return __ck.tag('i', arguments);};li = function(){return __ck.tag('li', arguments);};p = function(){return __ck.tag('p', arguments);};s = function(){return __ck.tag('s', arguments);};th = function(){return __ck.tag('th', arguments);};u = function(){return __ck.tag('u', arguments);};ul = function(){return __ck.tag('ul', arguments);};var __slice = Array.prototype.slice;var __hasProp = Object.prototype.hasOwnProperty;var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };var __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; };var __indexOf = Array.prototype.indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (this[i] === item) return i; } return -1; }; var coffeescript, comment, doctype, h, tag, text, __ck, _base, _base2, _ref, _ref2, _ref3; if ((_ref = data.options) != null) { _ref; } else { data.options = {}; }; if ((_ref2 = (_base = data.options).format) != null) { _ref2; } else { _base.format = false; }; if ((_ref3 = (_base2 = data.options).autoescape) != null) { _ref3; } else { _base2.autoescape = false; }; __ck = { options: data.options, buffer: [], doctypes: { '5': '<!DOCTYPE html>', 'xml': '<?xml version="1.0" encoding="utf-8" ?>', 'default': '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">', 'transitional': '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">', 'strict': '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">', 'frameset': '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">', '1.1': '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">', 'basic': '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.1//EN" "http://www.w3.org/TR/xhtml-basic/xhtml-basic11.dtd">', 'mobile': '<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.2//EN" "http://www.openmobilealliance.org/tech/DTD/xhtml-mobile12.dtd">', 'ce': '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "ce-html-1.0-transitional.dtd">' }, self_closing: ['area', 'base', 'basefont', 'br', 'col', 'frame', 'hr', 'img', 'input', 'link', 'meta', 'param'], render_attrs: function(obj) { var k, str, v; str = ''; for (k in obj) { v = obj[k]; str += " " + k + "=\"" + (this.esc(v)) + "\""; } return str; }, esc: function(txt) { if (this.options.autoescape) { return h(txt); } else { return String(txt); } }, tabs: 0, repeat: function(string, count) { return Array(count + 1).join(string); }, indent: function() { if (this.options.format) { return this.text(this.repeat(' ', this.tabs)); } }, tag: function(name, opts) { var o, result, _i, _j, _len, _len2; this.indent(); text("<" + name); for (_i = 0, _len = opts.length; _i < _len; _i++) { o = opts[_i]; if (typeof o === 'object') { text(this.render_attrs(o)); } } if (__indexOf.call(this.self_closing, name) >= 0) { text(' />'); if (this.options.format) { text('\n'); } } else { text('>'); for (_j = 0, _len2 = opts.length; _j < _len2; _j++) { o = opts[_j]; switch (typeof o) { case 'string': case 'number': text(this.esc(o)); break; case 'function': if (this.options.format) { text('\n'); } this.tabs++; result = o.call(data); if (typeof result === 'string') { this.indent(); text(this.esc(result)); if (this.options.format) { text('\n'); } } this.tabs--; this.indent(); } } text("</" + name + ">"); if (this.options.format) { text('\n'); } } return null; } }; h = function(txt) { return String(txt).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"'); }; doctype = function(type) { if (type == null) { type = 5; } text(__ck.doctypes[type]); if (data.options.format) { return text('\n'); } }; text = function(txt) { __ck.buffer.push(String(txt)); return null; }; comment = function(cmt) { text("<!--" + cmt + "-->"); if (data.options.format) { return text('\n'); } }; tag = function() { var name; name = arguments[0]; delete arguments[0]; return __ck.tag(name, arguments); }; coffeescript = function(code) { return script(";(" + code + ")();"); }; (function(){ul(function() { var guy, _i, _len, _ref, _results; _ref = this.stooges; _results = []; for (_i = 0, _len = _ref.length; _i < _len; _i++) { guy = _ref[_i]; _results.push(li(guy)); } return _results;});}).call(data);return __ck.buffer.join('');} | ||
(function(){ | ||
this.templates || (this.templates = {}); | ||
this.templates["template"] = function anonymous(data) { | ||
var a,i,li,p,s,th,u,ul;a = function(){return __ck.tag('a', arguments);};i = function(){return __ck.tag('i', arguments);};li = function(){return __ck.tag('li', arguments);};p = function(){return __ck.tag('p', arguments);};s = function(){return __ck.tag('s', arguments);};th = function(){return __ck.tag('th', arguments);};u = function(){return __ck.tag('u', arguments);};ul = function(){return __ck.tag('ul', arguments);};var __slice = Array.prototype.slice;var __hasProp = Object.prototype.hasOwnProperty;var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };var __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; };var __indexOf = Array.prototype.indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (this[i] === item) return i; } return -1; }; | ||
var coffeescript, comment, doctype, h, ie, tag, text, __ck, _ref, _ref2; | ||
if (data == null) { | ||
data = {}; | ||
} | ||
if ((_ref = data.format) != null) { | ||
_ref; | ||
} else { | ||
data.format = false; | ||
}; | ||
if ((_ref2 = data.autoescape) != null) { | ||
_ref2; | ||
} else { | ||
data.autoescape = false; | ||
}; | ||
__ck = { | ||
buffer: [], | ||
esc: function(txt) { | ||
if (data.autoescape) { | ||
return h(txt); | ||
} else { | ||
return String(txt); | ||
} | ||
}, | ||
tabs: 0, | ||
repeat: function(string, count) { | ||
return Array(count + 1).join(string); | ||
}, | ||
indent: function() { | ||
if (data.format) { | ||
return text(this.repeat(' ', this.tabs)); | ||
} | ||
}, | ||
tag: function(name, args) { | ||
var combo, i, _i, _len; | ||
combo = [name]; | ||
for (_i = 0, _len = args.length; _i < _len; _i++) { | ||
i = args[_i]; | ||
combo.push(i); | ||
} | ||
return tag.apply(data, combo); | ||
}, | ||
render_idclass: function(str) { | ||
var c, classes, i, id, _i, _j, _len, _len2, _ref3; | ||
classes = []; | ||
_ref3 = str.split('.'); | ||
for (_i = 0, _len = _ref3.length; _i < _len; _i++) { | ||
i = _ref3[_i]; | ||
if (i.indexOf('#') === 0) { | ||
id = i.replace('#', ''); | ||
} else { | ||
if (i !== '') { | ||
classes.push(i); | ||
} | ||
} | ||
} | ||
if (id) { | ||
text(" id=\"" + id + "\""); | ||
} | ||
if (classes.length > 0) { | ||
text(" class=\""); | ||
for (_j = 0, _len2 = classes.length; _j < _len2; _j++) { | ||
c = classes[_j]; | ||
if (c !== classes[0]) { | ||
text(' '); | ||
} | ||
text(c); | ||
} | ||
return text('"'); | ||
} | ||
}, | ||
render_attrs: function(obj) { | ||
var k, v, _results; | ||
_results = []; | ||
for (k in obj) { | ||
v = obj[k]; | ||
if (typeof v === 'boolean' && v) { | ||
v = k; | ||
} | ||
_results.push(v ? text(" " + k + "=\"" + (this.esc(v)) + "\"") : void 0); | ||
} | ||
return _results; | ||
}, | ||
render_contents: function(contents) { | ||
var result; | ||
switch (typeof contents) { | ||
case 'string': | ||
case 'number': | ||
case 'boolean': | ||
return text(this.esc(contents)); | ||
case 'function': | ||
if (data.format) { | ||
text('\n'); | ||
} | ||
this.tabs++; | ||
result = contents.call(data); | ||
if (typeof result === 'string') { | ||
this.indent(); | ||
text(this.esc(result)); | ||
if (data.format) { | ||
text('\n'); | ||
} | ||
} | ||
this.tabs--; | ||
return this.indent(); | ||
} | ||
}, | ||
render_tag: function(name, idclass, attrs, contents) { | ||
this.indent(); | ||
text("<" + name); | ||
if (idclass) { | ||
this.render_idclass(idclass); | ||
} | ||
if (attrs) { | ||
this.render_attrs(attrs); | ||
} | ||
if (__indexOf.call(this.self_closing, name) >= 0) { | ||
text(' />'); | ||
if (data.format) { | ||
text('\n'); | ||
} | ||
} else { | ||
text('>'); | ||
this.render_contents(contents); | ||
text("</" + name + ">"); | ||
if (data.format) { | ||
text('\n'); | ||
} | ||
} | ||
return null; | ||
} | ||
}; | ||
tag = function() { | ||
var a, args, attrs, contents, idclass, name, _i, _len; | ||
name = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : []; | ||
for (_i = 0, _len = args.length; _i < _len; _i++) { | ||
a = args[_i]; | ||
switch (typeof a) { | ||
case 'function': | ||
contents = a; | ||
break; | ||
case 'object': | ||
attrs = a; | ||
break; | ||
case 'number': | ||
case 'boolean': | ||
contents = a; | ||
break; | ||
case 'string': | ||
if (args.length === 1) { | ||
contents = a; | ||
} else { | ||
if (a === args[0]) { | ||
idclass = a; | ||
} else { | ||
contents = a; | ||
} | ||
} | ||
} | ||
} | ||
return __ck.render_tag(name, idclass, attrs, contents); | ||
}; | ||
h = function(txt) { | ||
return String(txt).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"'); | ||
}; | ||
doctype = function(type) { | ||
if (type == null) { | ||
type = 'default'; | ||
} | ||
text(__ck.doctypes[type]); | ||
if (data.format) { | ||
return text('\n'); | ||
} | ||
}; | ||
text = function(txt) { | ||
__ck.buffer.push(String(txt)); | ||
return null; | ||
}; | ||
comment = function(cmt) { | ||
text("<!--" + cmt + "-->"); | ||
if (data.format) { | ||
return text('\n'); | ||
} | ||
}; | ||
coffeescript = function(param) { | ||
switch (typeof param) { | ||
case 'function': | ||
return script("" + __ck.coffeescript_helpers + "(" + param + ").call(this);"); | ||
case 'string': | ||
return script({ | ||
type: 'text/coffeescript' | ||
}, function() { | ||
return param; | ||
}); | ||
case 'object': | ||
param.type = 'text/coffeescript'; | ||
return script(param); | ||
} | ||
}; | ||
ie = function(condition, contents) { | ||
__ck.indent(); | ||
text("<!--[if " + condition + "]>"); | ||
__ck.render_contents(contents); | ||
text("<![endif]-->"); | ||
if (data.format) { | ||
return text('\n'); | ||
} | ||
}; | ||
__ck.doctypes = {"5":"<!DOCTYPE html>","default":"<!DOCTYPE html>","xml":"<?xml version=\"1.0\" encoding=\"utf-8\" ?>","transitional":"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">","strict":"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">","frameset":"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Frameset//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd\">","1.1":"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">","basic":"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML Basic 1.1//EN\" \"http://www.w3.org/TR/xhtml-basic/xhtml-basic11.dtd\">","mobile":"<!DOCTYPE html PUBLIC \"-//WAPFORUM//DTD XHTML Mobile 1.2//EN\" \"http://www.openmobilealliance.org/tech/DTD/xhtml-mobile12.dtd\">","ce":"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"ce-html-1.0-transitional.dtd\">"};__ck.coffeescript_helpers = "var __slice = Array.prototype.slice;var __hasProp = Object.prototype.hasOwnProperty;var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };var __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; };var __indexOf = Array.prototype.indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (this[i] === item) return i; } return -1; };";__ck.self_closing = ["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr","basefont","frame"];(function(){ul(function() { | ||
var guy, _i, _len, _ref, _results; | ||
_ref = this.stooges; | ||
_results = []; | ||
for (_i = 0, _len = _ref.length; _i < _len; _i++) { | ||
guy = _ref[_i]; | ||
_results.push(li(guy)); | ||
} | ||
return _results; | ||
});}).call(data);return __ck.buffer.join(''); | ||
}; | ||
}).call(this); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/usr/bin/env sh | ||
coffeekup --js template.coffee | ||
coffee -c index.coffee | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
$().ready -> | ||
$('body').append template(stooges: ['moe', 'larry', 'curly']) | ||
$('body').append templates.template(stooges: ['moe', 'larry', 'curly']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.