Skip to content

Commit

Permalink
0.1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
satyr committed Jan 28, 2011
1 parent f4ce299 commit cf08be5
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 20 deletions.
15 changes: 8 additions & 7 deletions ckup.co
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
# `Ckup = require \ckup` in CommonJS, `self.Ckup` in browser etc.
Ckup = (exports ? @Ckup = {}) import
VERSION: \0.1.0
# `ckup = require \ckup` in CommonJS, `self.Ckup` in browser etc.
ckup = exports ? @Ckup = {}
ckup import
VERSION: \0.1.2

# `.call`s a `template` function with a `Ckup` clone set to `this` value,
# `.call`s a `template` function with a `ckup` clone set to `this` value,
# returning the rendered HTML string.
render: (template) ->
unless typeof template is \function
# If `template` isn't a function, compile it using `Coco` global
# with `with` with `this` to enable `@`-less style.
template = Function 'with(this)' +
(Coco ? require \coco).compile '' + template
(Coco ? require \coco).compile "#{template}"
# `@_` holds the HTML being built.
template.call me = @{_: ''}
me._
Expand Down Expand Up @@ -77,7 +78,7 @@ for tag of <[
]> then do ->
tailless = tag of <[ area base basefont br hr img input link meta ]>
# `@a href: url, ->` -> `@element \a, [href: url, ->]`
Ckup[tag] = -> @element tag, @@, tailless; void
ckup[tag] = -> @element tag, @@, tailless; void

# @$ is @quote # HTML-escape -> es -> S -> $
Ckup.$ = Ckup.quote
ckup.$ = ckup.quote
29 changes: 18 additions & 11 deletions ckup.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
(function(){
var Ckup, tag, _ref, _i, _len, __clone = function(it){
var ckup, tag, _i, _ref, _len, __clone = function(it){
function fn(){ if (this.__proto__ !== it) this.__proto__ = it }
return fn.prototype = it, new fn;
}, __slice = [].slice, _fn = function(tag){
var tailless;
tailless = tag === 'area' || tag === 'base' || tag === 'basefont' || tag === 'br' || tag === 'hr' || tag === 'img' || tag === 'input' || tag === 'link' || tag === 'meta';
return Ckup[tag] = function(){
return ckup[tag] = function(){
this.element(tag, arguments, tailless);
};
};
Ckup = (_ref = typeof exports != 'undefined' && exports !== null ? exports : this.Ckup = {}, _ref.VERSION = '0.1.0', _ref.render = function(template){
ckup = typeof exports != 'undefined' && exports !== null ? exports : this.Ckup = {};
ckup.VERSION = '0.1.2';
ckup.render = function(template){
var me, _ref;
if (typeof template !== 'function') {
template = Function('with(this)' + (typeof Coco != 'undefined' && Coco !== null ? Coco : require('coco')).compile('' + template));
template = Function('with(this)' + (typeof Coco != 'undefined' && Coco !== null ? Coco : require('coco')).compile("" + template));
}
template.call(me = (_ref = __clone(this), _ref._ = '', _ref));
return me._;
}, _ref.quote = (function(re, fn){
};
ckup.quote = (function(re, fn){
return function(it){
return ("" + it).replace(re, fn);
};
Expand All @@ -33,11 +36,14 @@
case '\'':
return '&#39;';
}
})), _ref.doctype = function(it){
}));
ckup.doctype = function(it){
this._ += "<!DOCTYPE " + it + ">";
}, _ref.text = function(it){
};
ckup.text = function(it){
this._ += this.quote(it);
}, _ref.element = function(name, args, tailless){
};
ckup.element = function(name, args, tailless){
var code, bodies, arg, key, val, body, _i, _len;
code = '<' + name;
bodies = [];
Expand Down Expand Up @@ -67,7 +73,8 @@
}
}
this._ += "</" + name + "\n>";
}, _ref.A = function(url, txt){
};
ckup.A = function(url, txt){
var args;
args = __slice.call(arguments);
args[0] = {
Expand All @@ -77,10 +84,10 @@
args[1] = url;
}
this.element('a', args);
}, _ref);
};
for (_i = 0, _len = (_ref = ['a', 'abbr', 'acronym', 'address', 'applet', 'area', 'article', 'aside', 'audio', 'b', 'base', 'basefont', 'bdo', 'big', 'blockquote', 'body', 'br', 'button', 'canvas', 'caption', 'center', 'cite', 'code', 'col', 'colgroup', 'command', 'datalist', 'dd', 'del', 'details', 'dfn', 'dir', 'div', 'dl', 'dt', 'em', 'embed', 'fieldset', 'figcaption', 'figure', 'font', 'footer', 'form', 'frame', 'frameset', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'header', 'hgroup', 'hr', 'html', 'i', 'iframe', 'img', 'input', 'ins', 'keygen', 'kbd', 'label', 'legend', 'li', 'link', 'map', 'mark', 'menu', 'meta', 'meter', 'nav', 'noframes', 'noscript', 'object', 'ol', 'optgroup', 'option', 'output', 'p', 'param', 'pre', 'progress', 'q', 'rp', 'rt', 'ruby', 's', 'samp', 'script', 'section', 'select', 'small', 'source', 'span', 'strike', 'strong', 'style', 'sub', 'summary', 'sup', 'table', 'tbody', 'td', 'textarea', 'tfoot', 'th', 'thead', 'time', 'title', 'tr', 'tt', 'u', 'ul', 'video', 'xmp']).length; _i < _len; ++_i) {
tag = _ref[_i];
_fn(tag);
}
Ckup.$ = Ckup.quote;
ckup.$ = ckup.quote;
}).call(this);
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{"name": "ckup", "version": "0.1.1"
{"name": "ckup", "version": "0.1.2"

,"description": "Markup as Coco"
,"keywords" : ["html", "template", "coco"]
Expand All @@ -11,7 +11,7 @@
,"homepage" : "http://satyr.github.com/ckup/"
,"repository": {"type": "git", "url": "git://github.com/satyr/ckup.git"}

,"engines": {"node": ">=0.2.5"}, "dependencies": {"coco": ">=0.2.2"}
,"engines": {"node": ">=0.2.5"}, "dependencies": {"coco": ">=0.3.0"}

,"main": "./ckup", "bin": {"ckup": "./cli.co"}
}

0 comments on commit cf08be5

Please sign in to comment.