id stringlengths 34 124 | type stringclasses 4
values | prompt stringlengths 0 4.95k | response stringlengths 21 4.89k | source_lang stringclasses 3
values | target_lang stringclasses 2
values | repo stringclasses 75
values | path stringlengths 10 88 | license stringclasses 1
value | commit stringlengths 40 40 | stars int64 431 18.7k | source_url stringlengths 86 176 | line_start int64 1 214 | line_end int64 3 253 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
mauricemach/coffeekup:lib/coffeekup.coffee:3:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
coffeekup.compile = (template, options) ->
options ?= {}
options.locals ?= {}
if typeof template is 'function' then template = String(template)
else if typeof template is 'string' and coffee?
template = coffee.compile template, {'noWrap'}
templat... | var cache;
coffeekup.compile = function(template, options) {
var code, i, j, k, len, len1, ref, t, tags_here, v;
if (options == null) {
options = {};
}
if (options.locals == null) {
options.locals = {};
}
if (typeof template === 'function') {
template = String(template);
} else if (typeof tem... | CoffeeScript | JavaScript | mauricemach/coffeekup | lib/coffeekup.coffee | MIT | 8262487772fd8853cd835ec41f19a7f3daa25472 | 1,245 | https://github.com/mauricemach/coffeekup/blob/8262487772fd8853cd835ec41f19a7f3daa25472/lib/coffeekup.coffee | 89 | 118 |
mauricemach/coffeekup:lib/coffeekup.coffee:3:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var cache;
coffeekup.compile = function(template, options) {
var code, i, j, k, len, len1, ref, t, tags_here, v;
if (options == null) {
options = {};
}
if (options.locals == null) {
options.locals = {};
}
if (typeof template === 'function') {
... | coffeekup.compile = (template, options) ->
options ?= {}
options.locals ?= {}
if typeof template is 'function' then template = String(template)
else if typeof template is 'string' and coffee?
template = coffee.compile template, {'noWrap'}
template = "function(){#{template}}"
tags_here = []
for t i... | JavaScript | CoffeeScript | mauricemach/coffeekup | lib/coffeekup.coffee | MIT | 8262487772fd8853cd835ec41f19a7f3daa25472 | 1,245 | https://github.com/mauricemach/coffeekup/blob/8262487772fd8853cd835ec41f19a7f3daa25472/lib/coffeekup.coffee | 89 | 118 |
mauricemach/coffeekup:lib/coffeekup.coffee:3:completion | completion | coffeekup.compile = (template, options) ->
options ?= {}
options.locals ?= {}
if typeof template is 'function' then template = String(template)
else if typeof template is 'string' and coffee?
template = coffee.compile template, {'noWrap'}
template = "function(){#{template}}"
tags_here = []
for t i... | for t in tags_here
code += "#{t} = function(){return tag('#{t}', arguments)};"
for k, v of options.locals
if typeof v is 'string' then code += "var #{k} = '#{v}';"
else code += "var #{k} = #{v};"
code += 'with(ck_options.locals){' if options.dynamic_locals
code += "(#{template}).call(ck_options.cont... | CoffeeScript | CoffeeScript | mauricemach/coffeekup | lib/coffeekup.coffee | MIT | 8262487772fd8853cd835ec41f19a7f3daa25472 | 1,245 | https://github.com/mauricemach/coffeekup/blob/8262487772fd8853cd835ec41f19a7f3daa25472/lib/coffeekup.coffee | 89 | 118 |
mauricemach/coffeekup:lib/coffeekup.coffee:1:raw_corpus | raw_corpus | unwrap = (code) ->
code = String(code)
if code.search /^(\s)*function/ > -1
code = code.replace /^(\s)*function(\s)*\(\)(\s)*\{/, ''
code = code.replace /\}(\s)*$/, '' | CoffeeScript | mauricemach/coffeekup | lib/coffeekup.coffee | MIT | 3f6cb5d5565915c67dde516027e0b42f887e1e46 | 1,245 | https://github.com/mauricemach/coffeekup/blob/3f6cb5d5565915c67dde516027e0b42f887e1e46/lib/coffeekup.coffee | 20 | 24 | ||
mauricemach/coffeekup:lib/coffeekup.coffee:1:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
unwrap = (code) ->
code = String(code)
if code.search /^(\s)*function/ > -1
code = code.replace /^(\s)*function(\s)*\(\)(\s)*\{/, ''
code = code.replace /\}(\s)*$/, ''
``` | var unwrap;
unwrap = function(code) {
code = String(code);
if (code.search(/^(\s)*function/ > -1)) {
code = code.replace(/^(\s)*function(\s)*\(\)(\s)*\{/, '');
return code = code.replace(/\}(\s)*$/, '');
}
}; | CoffeeScript | JavaScript | mauricemach/coffeekup | lib/coffeekup.coffee | MIT | 3f6cb5d5565915c67dde516027e0b42f887e1e46 | 1,245 | https://github.com/mauricemach/coffeekup/blob/3f6cb5d5565915c67dde516027e0b42f887e1e46/lib/coffeekup.coffee | 20 | 24 |
mauricemach/coffeekup:lib/coffeekup.coffee:1:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var unwrap;
unwrap = function(code) {
code = String(code);
if (code.search(/^(\s)*function/ > -1)) {
code = code.replace(/^(\s)*function(\s)*\(\)(\s)*\{/, '');
return code = code.replace(/\}(\s)*$/, '');
}
};
``` | unwrap = (code) ->
code = String(code)
if code.search /^(\s)*function/ > -1
code = code.replace /^(\s)*function(\s)*\(\)(\s)*\{/, ''
code = code.replace /\}(\s)*$/, '' | JavaScript | CoffeeScript | mauricemach/coffeekup | lib/coffeekup.coffee | MIT | 3f6cb5d5565915c67dde516027e0b42f887e1e46 | 1,245 | https://github.com/mauricemach/coffeekup/blob/3f6cb5d5565915c67dde516027e0b42f887e1e46/lib/coffeekup.coffee | 20 | 24 |
mauricemach/coffeekup:lib/coffeekup.coffee:1:completion | completion | unwrap = (code) ->
code = String(code) | if code.search /^(\s)*function/ > -1
code = code.replace /^(\s)*function(\s)*\(\)(\s)*\{/, ''
code = code.replace /\}(\s)*$/, '' | CoffeeScript | CoffeeScript | mauricemach/coffeekup | lib/coffeekup.coffee | MIT | 3f6cb5d5565915c67dde516027e0b42f887e1e46 | 1,245 | https://github.com/mauricemach/coffeekup/blob/3f6cb5d5565915c67dde516027e0b42f887e1e46/lib/coffeekup.coffee | 20 | 24 |
mauricemach/coffeekup:lib/coffeekup.coffee:2:raw_corpus | raw_corpus | render_attrs = (obj) ->
str = ''
for k, v of obj
str += " #{k}=\"#{v}\""
str | CoffeeScript | mauricemach/coffeekup | lib/coffeekup.coffee | MIT | 3f6cb5d5565915c67dde516027e0b42f887e1e46 | 1,245 | https://github.com/mauricemach/coffeekup/blob/3f6cb5d5565915c67dde516027e0b42f887e1e46/lib/coffeekup.coffee | 26 | 30 | ||
mauricemach/coffeekup:lib/coffeekup.coffee:2:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
render_attrs = (obj) ->
str = ''
for k, v of obj
str += " #{k}=\"#{v}\""
str
``` | var render_attrs;
render_attrs = function(obj) {
var k, str, v;
str = '';
for (k in obj) {
v = obj[k];
str += ` ${k}=\"${v}\"`;
}
return str;
}; | CoffeeScript | JavaScript | mauricemach/coffeekup | lib/coffeekup.coffee | MIT | 3f6cb5d5565915c67dde516027e0b42f887e1e46 | 1,245 | https://github.com/mauricemach/coffeekup/blob/3f6cb5d5565915c67dde516027e0b42f887e1e46/lib/coffeekup.coffee | 26 | 30 |
mauricemach/coffeekup:lib/coffeekup.coffee:2:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var render_attrs;
render_attrs = function(obj) {
var k, str, v;
str = '';
for (k in obj) {
v = obj[k];
str += ` ${k}=\"${v}\"`;
}
return str;
};
``` | render_attrs = (obj) ->
str = ''
for k, v of obj
str += " #{k}=\"#{v}\""
str | JavaScript | CoffeeScript | mauricemach/coffeekup | lib/coffeekup.coffee | MIT | 3f6cb5d5565915c67dde516027e0b42f887e1e46 | 1,245 | https://github.com/mauricemach/coffeekup/blob/3f6cb5d5565915c67dde516027e0b42f887e1e46/lib/coffeekup.coffee | 26 | 30 |
mauricemach/coffeekup:lib/coffeekup.coffee:2:completion | completion | render_attrs = (obj) ->
str = '' | for k, v of obj
str += " #{k}=\"#{v}\""
str | CoffeeScript | CoffeeScript | mauricemach/coffeekup | lib/coffeekup.coffee | MIT | 3f6cb5d5565915c67dde516027e0b42f887e1e46 | 1,245 | https://github.com/mauricemach/coffeekup/blob/3f6cb5d5565915c67dde516027e0b42f887e1e46/lib/coffeekup.coffee | 26 | 30 |
mauricemach/coffeekup:lib/coffeekup.coffee:3:raw_corpus | raw_corpus | class Locals
constructor: (@__options) ->
doctype: (type) ->
type ?= 5
@text doctypes[type]
@text '\n' if @__options.format
comment: (cmt) ->
@text "<!--#{cmt}-->"
@text '\n' if @__options.format
tag: (name, opts) ->
@text "<#{name}"
for o in opts
@text render_attrs(o) if t... | CoffeeScript | mauricemach/coffeekup | lib/coffeekup.coffee | MIT | 3f6cb5d5565915c67dde516027e0b42f887e1e46 | 1,245 | https://github.com/mauricemach/coffeekup/blob/3f6cb5d5565915c67dde516027e0b42f887e1e46/lib/coffeekup.coffee | 32 | 78 | ||
mauricemach/coffeekup:lib/coffeekup.coffee:3:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
class Locals
constructor: (@__options) ->
doctype: (type) ->
type ?= 5
@text doctypes[type]
@text '\n' if @__options.format
comment: (cmt) ->
@text "<!--#{cmt}-->"
@text '\n' if @__options.format
tag: (name, opts) ->
@text "<#{n... | var Locals, cached, i, len, t,
indexOf = [].indexOf;
Locals = class Locals {
constructor(__options) {
this.__options = __options;
}
doctype(type) {
if (type == null) {
type = 5;
}
this.text(doctypes[type]);
if (this.__options.format) {
return this.text('\n');
}
}
comme... | CoffeeScript | JavaScript | mauricemach/coffeekup | lib/coffeekup.coffee | MIT | 3f6cb5d5565915c67dde516027e0b42f887e1e46 | 1,245 | https://github.com/mauricemach/coffeekup/blob/3f6cb5d5565915c67dde516027e0b42f887e1e46/lib/coffeekup.coffee | 32 | 78 |
mauricemach/coffeekup:lib/coffeekup.coffee:3:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var Locals, cached, i, len, t,
indexOf = [].indexOf;
Locals = class Locals {
constructor(__options) {
this.__options = __options;
}
doctype(type) {
if (type == null) {
type = 5;
}
this.text(doctypes[type]);
if (this.__options.for... | class Locals
constructor: (@__options) ->
doctype: (type) ->
type ?= 5
@text doctypes[type]
@text '\n' if @__options.format
comment: (cmt) ->
@text "<!--#{cmt}-->"
@text '\n' if @__options.format
tag: (name, opts) ->
@text "<#{name}"
for o in opts
@text render_attrs(o) if t... | JavaScript | CoffeeScript | mauricemach/coffeekup | lib/coffeekup.coffee | MIT | 3f6cb5d5565915c67dde516027e0b42f887e1e46 | 1,245 | https://github.com/mauricemach/coffeekup/blob/3f6cb5d5565915c67dde516027e0b42f887e1e46/lib/coffeekup.coffee | 32 | 78 |
mauricemach/coffeekup:lib/coffeekup.coffee:3:completion | completion | class Locals
constructor: (@__options) ->
doctype: (type) ->
type ?= 5
@text doctypes[type]
@text '\n' if @__options.format
comment: (cmt) ->
@text "<!--#{cmt}-->"
@text '\n' if @__options.format
tag: (name, opts) ->
@text "<#{name}"
for o in opts
@text render_attrs(o) if t... | @text '\n' if @__options.format
for o in opts
switch typeof o
when 'string', 'number'
@text o
@text '\n' if @__options.format
when 'function'
result = o.call @__options.context
if typeof result is 'string'
@text result
... | CoffeeScript | CoffeeScript | mauricemach/coffeekup | lib/coffeekup.coffee | MIT | 3f6cb5d5565915c67dde516027e0b42f887e1e46 | 1,245 | https://github.com/mauricemach/coffeekup/blob/3f6cb5d5565915c67dde516027e0b42f887e1e46/lib/coffeekup.coffee | 32 | 78 |
mauricemach/coffeekup:lib/coffeekup.coffee:4:raw_corpus | raw_corpus | render = (template, options) ->
options ?= {}
options.context ?= {}
options.locals ?= {}
options.compact ?= off
options.cache ?= on
if options.locals.body?
options.context.body = options.locals.body
delete options.locals.body
buffer = []
locals = new Locals(options)
locals.text = (txt) -> bu... | CoffeeScript | mauricemach/coffeekup | lib/coffeekup.coffee | MIT | 3f6cb5d5565915c67dde516027e0b42f887e1e46 | 1,245 | https://github.com/mauricemach/coffeekup/blob/3f6cb5d5565915c67dde516027e0b42f887e1e46/lib/coffeekup.coffee | 80 | 123 | ||
mauricemach/coffeekup:lib/coffeekup.coffee:4:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
render = (template, options) ->
options ?= {}
options.context ?= {}
options.locals ?= {}
options.compact ?= off
options.cache ?= on
if options.locals.body?
options.context.body = options.locals.body
delete options.locals.body
buffer = []
... | var CoffeeKup, render;
render = function(template, options) {
var buffer, code, k, locals, ref, scoped_template, v;
if (options == null) {
options = {};
}
if (options.context == null) {
options.context = {};
}
if (options.locals == null) {
options.locals = {};
}
if (options.compact == null)... | CoffeeScript | JavaScript | mauricemach/coffeekup | lib/coffeekup.coffee | MIT | 3f6cb5d5565915c67dde516027e0b42f887e1e46 | 1,245 | https://github.com/mauricemach/coffeekup/blob/3f6cb5d5565915c67dde516027e0b42f887e1e46/lib/coffeekup.coffee | 80 | 123 |
mauricemach/coffeekup:lib/coffeekup.coffee:4:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var CoffeeKup, render;
render = function(template, options) {
var buffer, code, k, locals, ref, scoped_template, v;
if (options == null) {
options = {};
}
if (options.context == null) {
options.context = {};
}
if (options.locals == null) {
... | render = (template, options) ->
options ?= {}
options.context ?= {}
options.locals ?= {}
options.compact ?= off
options.cache ?= on
if options.locals.body?
options.context.body = options.locals.body
delete options.locals.body
buffer = []
locals = new Locals(options)
locals.text = (txt) -> bu... | JavaScript | CoffeeScript | mauricemach/coffeekup | lib/coffeekup.coffee | MIT | 3f6cb5d5565915c67dde516027e0b42f887e1e46 | 1,245 | https://github.com/mauricemach/coffeekup/blob/3f6cb5d5565915c67dde516027e0b42f887e1e46/lib/coffeekup.coffee | 80 | 123 |
mauricemach/coffeekup:lib/coffeekup.coffee:4:completion | completion | render = (template, options) ->
options ?= {}
options.context ?= {}
options.locals ?= {}
options.compact ?= off
options.cache ?= on
if options.locals.body?
options.context.body = options.locals.body
delete options.locals.body
buffer = []
locals = new Locals(options)
locals.text = (txt) -> bu... | when 'string'
if coffee? then code = coffee.compile template, {'noWrap'}
else code = unwrap(template)
when 'function' then code = unwrap(template)
else code = ''
scoped_template = new Function('locals', "with(locals){#{code}}")
cached[template] = scoped_template if options.cache
... | CoffeeScript | CoffeeScript | mauricemach/coffeekup | lib/coffeekup.coffee | MIT | 3f6cb5d5565915c67dde516027e0b42f887e1e46 | 1,245 | https://github.com/mauricemach/coffeekup/blob/3f6cb5d5565915c67dde516027e0b42f887e1e46/lib/coffeekup.coffee | 80 | 123 |
mauricemach/coffeekup:lib/coffeekup.coffee:2:raw_corpus | raw_corpus | class Locals
constructor: (@buffer, @context) ->
text: (txt) -> @buffer.push String(txt); null
render_attrs: (obj) ->
str = ''
for k, v of obj
str += " #{k}=\"#{v}\""
str
doctype: (type) ->
type ?= 5
@text doctypes[type]
comment: (cmt) ->
@text "<!--#{cmt}-->"
tag: (name, ... | CoffeeScript | mauricemach/coffeekup | lib/coffeekup.coffee | MIT | f18c1232ffd4afbfaef07732df8244a41b8a47fe | 1,245 | https://github.com/mauricemach/coffeekup/blob/f18c1232ffd4afbfaef07732df8244a41b8a47fe/lib/coffeekup.coffee | 26 | 69 | ||
mauricemach/coffeekup:lib/coffeekup.coffee:2:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
class Locals
constructor: (@buffer, @context) ->
text: (txt) -> @buffer.push String(txt); null
render_attrs: (obj) ->
str = ''
for k, v of obj
str += " #{k}=\"#{v}\""
str
doctype: (type) ->
type ?= 5
@text doctypes[type]
co... | var Locals, cached, i, len, t,
indexOf = [].indexOf;
Locals = class Locals {
constructor(buffer, context) {
this.buffer = buffer;
this.context = context;
}
text(txt) {
this.buffer.push(String(txt));
return null;
}
render_attrs(obj) {
var k, str, v;
str = '';
for (k in obj) {
... | CoffeeScript | JavaScript | mauricemach/coffeekup | lib/coffeekup.coffee | MIT | f18c1232ffd4afbfaef07732df8244a41b8a47fe | 1,245 | https://github.com/mauricemach/coffeekup/blob/f18c1232ffd4afbfaef07732df8244a41b8a47fe/lib/coffeekup.coffee | 26 | 69 |
mauricemach/coffeekup:lib/coffeekup.coffee:2:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var Locals, cached, i, len, t,
indexOf = [].indexOf;
Locals = class Locals {
constructor(buffer, context) {
this.buffer = buffer;
this.context = context;
}
text(txt) {
this.buffer.push(String(txt));
return null;
}
render_attrs(obj) {
... | class Locals
constructor: (@buffer, @context) ->
text: (txt) -> @buffer.push String(txt); null
render_attrs: (obj) ->
str = ''
for k, v of obj
str += " #{k}=\"#{v}\""
str
doctype: (type) ->
type ?= 5
@text doctypes[type]
comment: (cmt) ->
@text "<!--#{cmt}-->"
tag: (name, ... | JavaScript | CoffeeScript | mauricemach/coffeekup | lib/coffeekup.coffee | MIT | f18c1232ffd4afbfaef07732df8244a41b8a47fe | 1,245 | https://github.com/mauricemach/coffeekup/blob/f18c1232ffd4afbfaef07732df8244a41b8a47fe/lib/coffeekup.coffee | 26 | 69 |
mauricemach/coffeekup:lib/coffeekup.coffee:2:completion | completion | class Locals
constructor: (@buffer, @context) ->
text: (txt) -> @buffer.push String(txt); null
render_attrs: (obj) ->
str = ''
for k, v of obj
str += " #{k}=\"#{v}\""
str
doctype: (type) ->
type ?= 5
@text doctypes[type]
comment: (cmt) ->
@text "<!--#{cmt}-->"
tag: (name, ... | if name in self_closing
@text ' />'
else
@text '>'
for o in opts
t = typeof o
if t is 'function'
result = o.call @context
@text result if typeof result is 'string'
else if t is 'string' or t is 'number' then @text o
@text "</#{name}>"
null
... | CoffeeScript | CoffeeScript | mauricemach/coffeekup | lib/coffeekup.coffee | MIT | f18c1232ffd4afbfaef07732df8244a41b8a47fe | 1,245 | https://github.com/mauricemach/coffeekup/blob/f18c1232ffd4afbfaef07732df8244a41b8a47fe/lib/coffeekup.coffee | 26 | 69 |
mauricemach/coffeekup:lib/coffeekup.coffee:3:raw_corpus | raw_corpus | render = (template, options) ->
options ?= {}
options.context ?= {}
options.locals ?= {}
options.cache ?= on
buffer = []
context = options.context
locals = new Locals(buffer, context)
for k, v of options.locals
locals[k] = v
if options.locals.body?
context.body = options.locals.body
del... | CoffeeScript | mauricemach/coffeekup | lib/coffeekup.coffee | MIT | f18c1232ffd4afbfaef07732df8244a41b8a47fe | 1,245 | https://github.com/mauricemach/coffeekup/blob/f18c1232ffd4afbfaef07732df8244a41b8a47fe/lib/coffeekup.coffee | 71 | 113 | ||
mauricemach/coffeekup:lib/coffeekup.coffee:3:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
render = (template, options) ->
options ?= {}
options.context ?= {}
options.locals ?= {}
options.cache ?= on
buffer = []
context = options.context
locals = new Locals(buffer, context)
for k, v of options.locals
locals[k] = v
if options.lo... | var CoffeeKup, render;
render = function(template, options) {
var buffer, code, context, k, locals, ref, scoped_template, v;
if (options == null) {
options = {};
}
if (options.context == null) {
options.context = {};
}
if (options.locals == null) {
options.locals = {};
}
if (options.cache =... | CoffeeScript | JavaScript | mauricemach/coffeekup | lib/coffeekup.coffee | MIT | f18c1232ffd4afbfaef07732df8244a41b8a47fe | 1,245 | https://github.com/mauricemach/coffeekup/blob/f18c1232ffd4afbfaef07732df8244a41b8a47fe/lib/coffeekup.coffee | 71 | 113 |
mauricemach/coffeekup:lib/coffeekup.coffee:3:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var CoffeeKup, render;
render = function(template, options) {
var buffer, code, context, k, locals, ref, scoped_template, v;
if (options == null) {
options = {};
}
if (options.context == null) {
options.context = {};
}
if (options.locals == nul... | render = (template, options) ->
options ?= {}
options.context ?= {}
options.locals ?= {}
options.cache ?= on
buffer = []
context = options.context
locals = new Locals(buffer, context)
for k, v of options.locals
locals[k] = v
if options.locals.body?
context.body = options.locals.body
del... | JavaScript | CoffeeScript | mauricemach/coffeekup | lib/coffeekup.coffee | MIT | f18c1232ffd4afbfaef07732df8244a41b8a47fe | 1,245 | https://github.com/mauricemach/coffeekup/blob/f18c1232ffd4afbfaef07732df8244a41b8a47fe/lib/coffeekup.coffee | 71 | 113 |
mauricemach/coffeekup:lib/coffeekup.coffee:3:completion | completion | render = (template, options) ->
options ?= {}
options.context ?= {}
options.locals ?= {}
options.cache ?= on
buffer = []
context = options.context
locals = new Locals(buffer, context)
for k, v of options.locals
locals[k] = v
if options.locals.body?
context.body = options.locals.body
del... | when 'string'
if coffee? then code = coffee.compile template, {'noWrap'}
else code = unwrap(template)
when 'function' then code = unwrap(template)
else code = ''
scoped_template = new Function('locals', "with(locals){#{code}}")
cached[template] = scoped_template if options.cache
... | CoffeeScript | CoffeeScript | mauricemach/coffeekup | lib/coffeekup.coffee | MIT | f18c1232ffd4afbfaef07732df8244a41b8a47fe | 1,245 | https://github.com/mauricemach/coffeekup/blob/f18c1232ffd4afbfaef07732df8244a41b8a47fe/lib/coffeekup.coffee | 71 | 113 |
mauricemach/coffeekup:lib/coffeekup.coffee:3:raw_corpus | raw_corpus | render = (template, options) ->
options ?= {}
options.context ?= {}
options.locals ?= {}
options.cache ?= on
buffer = []
context = options.context
locals = new Locals(buffer, context)
if options.locals.body?
context.body = options.locals.body
delete options.locals.body
if options.cache and ... | CoffeeScript | mauricemach/coffeekup | lib/coffeekup.coffee | MIT | 0ef7cbc479d602c7c601973bd01c66cae004c931 | 1,245 | https://github.com/mauricemach/coffeekup/blob/0ef7cbc479d602c7c601973bd01c66cae004c931/lib/coffeekup.coffee | 71 | 110 | ||
mauricemach/coffeekup:lib/coffeekup.coffee:3:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
render = (template, options) ->
options ?= {}
options.context ?= {}
options.locals ?= {}
options.cache ?= on
buffer = []
context = options.context
locals = new Locals(buffer, context)
if options.locals.body?
context.body = options.locals.bod... | var CoffeeKup, render;
render = function(template, options) {
var buffer, code, context, locals, scoped_template;
if (options == null) {
options = {};
}
if (options.context == null) {
options.context = {};
}
if (options.locals == null) {
options.locals = {};
}
if (options.cache == null) {
... | CoffeeScript | JavaScript | mauricemach/coffeekup | lib/coffeekup.coffee | MIT | 0ef7cbc479d602c7c601973bd01c66cae004c931 | 1,245 | https://github.com/mauricemach/coffeekup/blob/0ef7cbc479d602c7c601973bd01c66cae004c931/lib/coffeekup.coffee | 71 | 110 |
mauricemach/coffeekup:lib/coffeekup.coffee:3:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var CoffeeKup, render;
render = function(template, options) {
var buffer, code, context, locals, scoped_template;
if (options == null) {
options = {};
}
if (options.context == null) {
options.context = {};
}
if (options.locals == null) {
op... | render = (template, options) ->
options ?= {}
options.context ?= {}
options.locals ?= {}
options.cache ?= on
buffer = []
context = options.context
locals = new Locals(buffer, context)
if options.locals.body?
context.body = options.locals.body
delete options.locals.body
if options.cache and ... | JavaScript | CoffeeScript | mauricemach/coffeekup | lib/coffeekup.coffee | MIT | 0ef7cbc479d602c7c601973bd01c66cae004c931 | 1,245 | https://github.com/mauricemach/coffeekup/blob/0ef7cbc479d602c7c601973bd01c66cae004c931/lib/coffeekup.coffee | 71 | 110 |
mauricemach/coffeekup:lib/coffeekup.coffee:3:completion | completion | render = (template, options) ->
options ?= {}
options.context ?= {}
options.locals ?= {}
options.cache ?= on
buffer = []
context = options.context
locals = new Locals(buffer, context)
if options.locals.body?
context.body = options.locals.body
delete options.locals.body
if options.cache and ... | else code = unwrap(template)
when 'function' then code = unwrap(template)
else code = ''
scoped_template = new Function('locals', "with(locals){#{code}}")
cached[template] = scoped_template if options.cache
scoped_template.call context, locals
buffer.pop() if buffer[buffer.length-1] is "\n"
... | CoffeeScript | CoffeeScript | mauricemach/coffeekup | lib/coffeekup.coffee | MIT | 0ef7cbc479d602c7c601973bd01c66cae004c931 | 1,245 | https://github.com/mauricemach/coffeekup/blob/0ef7cbc479d602c7c601973bd01c66cae004c931/lib/coffeekup.coffee | 71 | 110 |
mauricemach/coffeekup:lib/coffeekup.coffee:2:raw_corpus | raw_corpus | locals =
render_attrs: (obj) ->
str = ''
for k, v of obj
str += " #{k}=\"#{v}\""
str
doctype: (type) ->
type ?= 5
@text doctypes[type]
comment: (cmt) ->
@text "<!--#{cmt}-->"
tag: (name, opts) ->
@text "<#{name}"
for o in opts
@text @render_attrs(o) if typeof o is ... | CoffeeScript | mauricemach/coffeekup | lib/coffeekup.coffee | MIT | 24430af12f24776d385b29dfd74d30105b3d430b | 1,245 | https://github.com/mauricemach/coffeekup/blob/24430af12f24776d385b29dfd74d30105b3d430b/lib/coffeekup.coffee | 26 | 66 | ||
mauricemach/coffeekup:lib/coffeekup.coffee:2:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
locals =
render_attrs: (obj) ->
str = ''
for k, v of obj
str += " #{k}=\"#{v}\""
str
doctype: (type) ->
type ?= 5
@text doctypes[type]
comment: (cmt) ->
@text "<!--#{cmt}-->"
tag: (name, opts) ->
@text "<#{name}"
f... | var cached, context, i, len, locals, t,
indexOf = [].indexOf;
locals = {
render_attrs: function(obj) {
var k, str, v;
str = '';
for (k in obj) {
v = obj[k];
str += ` ${k}=\"${v}\"`;
}
return str;
},
doctype: function(type) {
if (type == null) {
type = 5;
}
retu... | CoffeeScript | JavaScript | mauricemach/coffeekup | lib/coffeekup.coffee | MIT | 24430af12f24776d385b29dfd74d30105b3d430b | 1,245 | https://github.com/mauricemach/coffeekup/blob/24430af12f24776d385b29dfd74d30105b3d430b/lib/coffeekup.coffee | 26 | 66 |
mauricemach/coffeekup:lib/coffeekup.coffee:2:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var cached, context, i, len, locals, t,
indexOf = [].indexOf;
locals = {
render_attrs: function(obj) {
var k, str, v;
str = '';
for (k in obj) {
v = obj[k];
str += ` ${k}=\"${v}\"`;
}
return str;
},
doctype: function(type) {... | locals =
render_attrs: (obj) ->
str = ''
for k, v of obj
str += " #{k}=\"#{v}\""
str
doctype: (type) ->
type ?= 5
@text doctypes[type]
comment: (cmt) ->
@text "<!--#{cmt}-->"
tag: (name, opts) ->
@text "<#{name}"
for o in opts
@text @render_attrs(o) if typeof o is ... | JavaScript | CoffeeScript | mauricemach/coffeekup | lib/coffeekup.coffee | MIT | 24430af12f24776d385b29dfd74d30105b3d430b | 1,245 | https://github.com/mauricemach/coffeekup/blob/24430af12f24776d385b29dfd74d30105b3d430b/lib/coffeekup.coffee | 26 | 66 |
mauricemach/coffeekup:lib/coffeekup.coffee:2:completion | completion | locals =
render_attrs: (obj) ->
str = ''
for k, v of obj
str += " #{k}=\"#{v}\""
str
doctype: (type) ->
type ?= 5
@text doctypes[type]
comment: (cmt) ->
@text "<!--#{cmt}-->"
tag: (name, opts) ->
@text "<#{name}"
for o in opts
@text @render_attrs(o) if typeof o is ... | @text ' />'
else
@text '>'
for o in opts
t = typeof o
if t is 'function'
result = o.call context
@text result if typeof result is 'string'
else if t is 'string' or t is 'number' then @text o
@text "</#{name}>"
null
coffeescript: (code) ->
@sc... | CoffeeScript | CoffeeScript | mauricemach/coffeekup | lib/coffeekup.coffee | MIT | 24430af12f24776d385b29dfd74d30105b3d430b | 1,245 | https://github.com/mauricemach/coffeekup/blob/24430af12f24776d385b29dfd74d30105b3d430b/lib/coffeekup.coffee | 26 | 66 |
mauricemach/coffeekup:lib/coffeekup.coffee:3:raw_corpus | raw_corpus | render = (template, options) ->
options ?= {}
options.context ?= {}
options.locals ?= {}
options.cache ?= on
buffer = []
locals.text = (txt) -> buffer.push String(txt); null
context = options.context
if options.locals.body?
context.body = options.locals.body
delete options.locals.body
if op... | CoffeeScript | mauricemach/coffeekup | lib/coffeekup.coffee | MIT | 24430af12f24776d385b29dfd74d30105b3d430b | 1,245 | https://github.com/mauricemach/coffeekup/blob/24430af12f24776d385b29dfd74d30105b3d430b/lib/coffeekup.coffee | 68 | 107 | ||
mauricemach/coffeekup:lib/coffeekup.coffee:3:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
render = (template, options) ->
options ?= {}
options.context ?= {}
options.locals ?= {}
options.cache ?= on
buffer = []
locals.text = (txt) -> buffer.push String(txt); null
context = options.context
if options.locals.body?
context.body = op... | var CoffeeKup, render;
render = function(template, options) {
var buffer, code, context, scoped_template;
if (options == null) {
options = {};
}
if (options.context == null) {
options.context = {};
}
if (options.locals == null) {
options.locals = {};
}
if (options.cache == null) {
optio... | CoffeeScript | JavaScript | mauricemach/coffeekup | lib/coffeekup.coffee | MIT | 24430af12f24776d385b29dfd74d30105b3d430b | 1,245 | https://github.com/mauricemach/coffeekup/blob/24430af12f24776d385b29dfd74d30105b3d430b/lib/coffeekup.coffee | 68 | 107 |
mauricemach/coffeekup:lib/coffeekup.coffee:3:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var CoffeeKup, render;
render = function(template, options) {
var buffer, code, context, scoped_template;
if (options == null) {
options = {};
}
if (options.context == null) {
options.context = {};
}
if (options.locals == null) {
options.lo... | render = (template, options) ->
options ?= {}
options.context ?= {}
options.locals ?= {}
options.cache ?= on
buffer = []
locals.text = (txt) -> buffer.push String(txt); null
context = options.context
if options.locals.body?
context.body = options.locals.body
delete options.locals.body
if op... | JavaScript | CoffeeScript | mauricemach/coffeekup | lib/coffeekup.coffee | MIT | 24430af12f24776d385b29dfd74d30105b3d430b | 1,245 | https://github.com/mauricemach/coffeekup/blob/24430af12f24776d385b29dfd74d30105b3d430b/lib/coffeekup.coffee | 68 | 107 |
mauricemach/coffeekup:lib/coffeekup.coffee:3:completion | completion | render = (template, options) ->
options ?= {}
options.context ?= {}
options.locals ?= {}
options.cache ?= on
buffer = []
locals.text = (txt) -> buffer.push String(txt); null
context = options.context
if options.locals.body?
context.body = options.locals.body
delete options.locals.body
if op... | else code = unwrap(template)
when 'function' then code = unwrap(template)
else code = ''
scoped_template = new Function('locals', "with(locals){#{code}}")
cached[template] = scoped_template if options.cache
scoped_template.call context, locals
buffer.pop() if buffer[buffer.length-1] is "\n"
... | CoffeeScript | CoffeeScript | mauricemach/coffeekup | lib/coffeekup.coffee | MIT | 24430af12f24776d385b29dfd74d30105b3d430b | 1,245 | https://github.com/mauricemach/coffeekup/blob/24430af12f24776d385b29dfd74d30105b3d430b/lib/coffeekup.coffee | 68 | 107 |
mauricemach/coffeekup:lib/coffeekup.coffee:2:raw_corpus | raw_corpus | locals =
render_attrs: (obj) ->
str = ''
for k, v of obj
str += " #{k}=\"#{v}\""
str
doctype: (type) ->
type ?= 5
@text doctypes[type]
comment: (cmt) ->
@text "<!--#{cmt}-->"
tag: (name, opts) ->
@text "<#{name}"
for o in opts
@text @render_attrs(o) if typeof o is ... | CoffeeScript | mauricemach/coffeekup | lib/coffeekup.coffee | MIT | b380123baeb5b1f8b7bdfce9a09b8a0c2674cd39 | 1,245 | https://github.com/mauricemach/coffeekup/blob/b380123baeb5b1f8b7bdfce9a09b8a0c2674cd39/lib/coffeekup.coffee | 26 | 65 | ||
mauricemach/coffeekup:lib/coffeekup.coffee:2:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
locals =
render_attrs: (obj) ->
str = ''
for k, v of obj
str += " #{k}=\"#{v}\""
str
doctype: (type) ->
type ?= 5
@text doctypes[type]
comment: (cmt) ->
@text "<!--#{cmt}-->"
tag: (name, opts) ->
@text "<#{name}"
f... | var cached, i, len, locals, t,
indexOf = [].indexOf;
locals = {
render_attrs: function(obj) {
var k, str, v;
str = '';
for (k in obj) {
v = obj[k];
str += ` ${k}=\"${v}\"`;
}
return str;
},
doctype: function(type) {
if (type == null) {
type = 5;
}
return this.t... | CoffeeScript | JavaScript | mauricemach/coffeekup | lib/coffeekup.coffee | MIT | b380123baeb5b1f8b7bdfce9a09b8a0c2674cd39 | 1,245 | https://github.com/mauricemach/coffeekup/blob/b380123baeb5b1f8b7bdfce9a09b8a0c2674cd39/lib/coffeekup.coffee | 26 | 65 |
mauricemach/coffeekup:lib/coffeekup.coffee:2:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var cached, i, len, locals, t,
indexOf = [].indexOf;
locals = {
render_attrs: function(obj) {
var k, str, v;
str = '';
for (k in obj) {
v = obj[k];
str += ` ${k}=\"${v}\"`;
}
return str;
},
doctype: function(type) {
if (... | locals =
render_attrs: (obj) ->
str = ''
for k, v of obj
str += " #{k}=\"#{v}\""
str
doctype: (type) ->
type ?= 5
@text doctypes[type]
comment: (cmt) ->
@text "<!--#{cmt}-->"
tag: (name, opts) ->
@text "<#{name}"
for o in opts
@text @render_attrs(o) if typeof o is ... | JavaScript | CoffeeScript | mauricemach/coffeekup | lib/coffeekup.coffee | MIT | b380123baeb5b1f8b7bdfce9a09b8a0c2674cd39 | 1,245 | https://github.com/mauricemach/coffeekup/blob/b380123baeb5b1f8b7bdfce9a09b8a0c2674cd39/lib/coffeekup.coffee | 26 | 65 |
mauricemach/coffeekup:lib/coffeekup.coffee:2:completion | completion | locals =
render_attrs: (obj) ->
str = ''
for k, v of obj
str += " #{k}=\"#{v}\""
str
doctype: (type) ->
type ?= 5
@text doctypes[type]
comment: (cmt) ->
@text "<!--#{cmt}-->"
tag: (name, opts) ->
@text "<#{name}"
for o in opts
@text @render_attrs(o) if typeof o is ... | @text ' />'
else
@text '>'
for o in opts
t = typeof o
if t is 'function'
result = o.call @context
@text result if typeof result is 'string'
else if t is 'string' or t is 'number' then @text o
@text "</#{name}>"
null
coffeescript: (code) ->
@s... | CoffeeScript | CoffeeScript | mauricemach/coffeekup | lib/coffeekup.coffee | MIT | b380123baeb5b1f8b7bdfce9a09b8a0c2674cd39 | 1,245 | https://github.com/mauricemach/coffeekup/blob/b380123baeb5b1f8b7bdfce9a09b8a0c2674cd39/lib/coffeekup.coffee | 26 | 65 |
mauricemach/coffeekup:lib/coffeekup.coffee:3:raw_corpus | raw_corpus | render = (template, options) ->
options ?= {}
options.cache ?= on
buffer = []
locals.text = (txt) -> buffer.push String(txt); null
locals.context = options.context or {}
if options.cache and cached[template]?
scoped_template = cached[template]
else
switch typeof template
when 'string'
... | CoffeeScript | mauricemach/coffeekup | lib/coffeekup.coffee | MIT | b380123baeb5b1f8b7bdfce9a09b8a0c2674cd39 | 1,245 | https://github.com/mauricemach/coffeekup/blob/b380123baeb5b1f8b7bdfce9a09b8a0c2674cd39/lib/coffeekup.coffee | 67 | 100 | ||
mauricemach/coffeekup:lib/coffeekup.coffee:3:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
render = (template, options) ->
options ?= {}
options.cache ?= on
buffer = []
locals.text = (txt) -> buffer.push String(txt); null
locals.context = options.context or {}
if options.cache and cached[template]?
scoped_template = cached[template]
... | var CoffeeKup, render;
render = function(template, options) {
var buffer, code, scoped_template;
if (options == null) {
options = {};
}
if (options.cache == null) {
options.cache = true;
}
buffer = [];
locals.text = function(txt) {
buffer.push(String(txt));
return null;
};
locals.cont... | CoffeeScript | JavaScript | mauricemach/coffeekup | lib/coffeekup.coffee | MIT | b380123baeb5b1f8b7bdfce9a09b8a0c2674cd39 | 1,245 | https://github.com/mauricemach/coffeekup/blob/b380123baeb5b1f8b7bdfce9a09b8a0c2674cd39/lib/coffeekup.coffee | 67 | 100 |
mauricemach/coffeekup:lib/coffeekup.coffee:3:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var CoffeeKup, render;
render = function(template, options) {
var buffer, code, scoped_template;
if (options == null) {
options = {};
}
if (options.cache == null) {
options.cache = true;
}
buffer = [];
locals.text = function(txt) {
buffer... | render = (template, options) ->
options ?= {}
options.cache ?= on
buffer = []
locals.text = (txt) -> buffer.push String(txt); null
locals.context = options.context or {}
if options.cache and cached[template]?
scoped_template = cached[template]
else
switch typeof template
when 'string'
... | JavaScript | CoffeeScript | mauricemach/coffeekup | lib/coffeekup.coffee | MIT | b380123baeb5b1f8b7bdfce9a09b8a0c2674cd39 | 1,245 | https://github.com/mauricemach/coffeekup/blob/b380123baeb5b1f8b7bdfce9a09b8a0c2674cd39/lib/coffeekup.coffee | 67 | 100 |
mauricemach/coffeekup:lib/coffeekup.coffee:3:completion | completion | render = (template, options) ->
options ?= {}
options.cache ?= on
buffer = []
locals.text = (txt) -> buffer.push String(txt); null
locals.context = options.context or {}
if options.cache and cached[template]?
scoped_template = cached[template]
else
switch typeof template
when 'string'
... | scoped_template = new Function('locals', "with(locals){#{code}}")
cached[template] = scoped_template if options.cache
scoped_template.call locals.context, locals
buffer.pop() if buffer[buffer.length-1] is "\n"
buffer.join ''
CoffeeKup = version: version, render: render
if window? then window.CoffeeKup = Co... | CoffeeScript | CoffeeScript | mauricemach/coffeekup | lib/coffeekup.coffee | MIT | b380123baeb5b1f8b7bdfce9a09b8a0c2674cd39 | 1,245 | https://github.com/mauricemach/coffeekup/blob/b380123baeb5b1f8b7bdfce9a09b8a0c2674cd39/lib/coffeekup.coffee | 67 | 100 |
mauricemach/coffeekup:lib/coffeekup.coffee:1:raw_corpus | raw_corpus | class CoffeeKup
@version: '0.1.6'
@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 "-//W3... | CoffeeScript | mauricemach/coffeekup | lib/coffeekup.coffee | MIT | aefcb7cc109f40f6133c30a017f5e3f1cfa79376 | 1,245 | https://github.com/mauricemach/coffeekup/blob/aefcb7cc109f40f6133c30a017f5e3f1cfa79376/lib/coffeekup.coffee | 8 | 57 | ||
mauricemach/coffeekup:lib/coffeekup.coffee:1:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
class CoffeeKup
@version: '0.1.6'
@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... | var CoffeeKup;
CoffeeKup = (function() {
class CoffeeKup {
static unwrap(code) {
code = String(code);
if (code.search(/^(\s)*function/ > -1)) {
code = code.replace(/^(\s)*function(\s)*\(\)(\s)*\{/, '');
return code = code.replace(/\}(\s)*$/, '');
}
}
static render(templ... | CoffeeScript | JavaScript | mauricemach/coffeekup | lib/coffeekup.coffee | MIT | aefcb7cc109f40f6133c30a017f5e3f1cfa79376 | 1,245 | https://github.com/mauricemach/coffeekup/blob/aefcb7cc109f40f6133c30a017f5e3f1cfa79376/lib/coffeekup.coffee | 8 | 57 |
mauricemach/coffeekup:lib/coffeekup.coffee:1:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var CoffeeKup;
CoffeeKup = (function() {
class CoffeeKup {
static unwrap(code) {
code = String(code);
if (code.search(/^(\s)*function/ > -1)) {
code = code.replace(/^(\s)*function(\s)*\(\)(\s)*\{/, '');
return code = code.replace(... | class CoffeeKup
@version: '0.1.6'
@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 "-//W3... | JavaScript | CoffeeScript | mauricemach/coffeekup | lib/coffeekup.coffee | MIT | aefcb7cc109f40f6133c30a017f5e3f1cfa79376 | 1,245 | https://github.com/mauricemach/coffeekup/blob/aefcb7cc109f40f6133c30a017f5e3f1cfa79376/lib/coffeekup.coffee | 8 | 57 |
mauricemach/coffeekup:lib/coffeekup.coffee:1:completion | completion | class CoffeeKup
@version: '0.1.6'
@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 "-//W3... | @cache: {}
@render: (template, options) ->
options ?= {}
options.cache ?= off
options.compact ?= off
buffer = []
context = options.context or {}
locals = options.locals or {}
if locals.body?
context.body = locals.body
delete locals.body
text = (txt) -> buffer.push txt; ... | CoffeeScript | CoffeeScript | mauricemach/coffeekup | lib/coffeekup.coffee | MIT | aefcb7cc109f40f6133c30a017f5e3f1cfa79376 | 1,245 | https://github.com/mauricemach/coffeekup/blob/aefcb7cc109f40f6133c30a017f5e3f1cfa79376/lib/coffeekup.coffee | 8 | 57 |
mauricemach/coffeekup:lib/coffeekup.coffee:2:raw_corpus | raw_corpus | text CoffeeKup.doctypes[type]
text "\n" unless options.compact
comment = (cmt) ->
text "<!--#{cmt}-->"
tag = (name, opts) ->
text "<#{name}"
for o in opts
text render_attrs(o) if typeof o is 'object'
if name in CoffeeKup.self_closing
text ' />'
else
... | CoffeeScript | mauricemach/coffeekup | lib/coffeekup.coffee | MIT | aefcb7cc109f40f6133c30a017f5e3f1cfa79376 | 1,245 | https://github.com/mauricemach/coffeekup/blob/aefcb7cc109f40f6133c30a017f5e3f1cfa79376/lib/coffeekup.coffee | 58 | 107 | ||
mauricemach/coffeekup:lib/coffeekup.coffee:2:completion | completion | text CoffeeKup.doctypes[type]
text "\n" unless options.compact
comment = (cmt) ->
text "<!--#{cmt}-->"
tag = (name, opts) ->
text "<#{name}"
for o in opts
text render_attrs(o) if typeof o is 'object'
if name in CoffeeKup.self_closing
text ' />'
else
... | null
coffeescript = (code) ->
tag 'script', "(#{code})();"
locals =
text: text
render_attrs: render_attrs
doctype: doctype
comment: comment
tag: tag
coffeescript: coffeescript
for t in @tags
locals[t] = -> tag t, arguments
if options.cache and @cache[... | CoffeeScript | CoffeeScript | mauricemach/coffeekup | lib/coffeekup.coffee | MIT | aefcb7cc109f40f6133c30a017f5e3f1cfa79376 | 1,245 | https://github.com/mauricemach/coffeekup/blob/aefcb7cc109f40f6133c30a017f5e3f1cfa79376/lib/coffeekup.coffee | 58 | 107 |
mauricemach/coffeekup:lib/coffeekup.coffee:3:raw_corpus | raw_corpus | else code = ''
scoped_template = new Function('locals', "with(locals){#{code}}")
@cache[template] = scoped_template if options.cache
scoped_template.call context, locals
buffer.pop() if buffer[buffer.length-1] is "\n"
buffer.join ''
root.CoffeeKup = CoffeeKup
root.version = CoffeeKup.version
... | CoffeeScript | mauricemach/coffeekup | lib/coffeekup.coffee | MIT | aefcb7cc109f40f6133c30a017f5e3f1cfa79376 | 1,245 | https://github.com/mauricemach/coffeekup/blob/aefcb7cc109f40f6133c30a017f5e3f1cfa79376/lib/coffeekup.coffee | 108 | 129 | ||
mauricemach/coffeekup:lib/coffeekup.coffee:3:completion | completion | else code = ''
scoped_template = new Function('locals', "with(locals){#{code}}")
@cache[template] = scoped_template if options.cache
scoped_template.call context, locals
buffer.pop() if buffer[buffer.length-1] is "\n"
buffer.join ''
root.CoffeeKup = CoffeeKup
root.version = CoffeeKup.version | unless browser
root.render = (template, options) ->
CoffeeKup.render(template, options)
root.adapters = {}
root.adapters.simple = (template, data) ->
CoffeeKup.render(template, {context: data})
root.adapters.meryl = root.adapters.simple | CoffeeScript | CoffeeScript | mauricemach/coffeekup | lib/coffeekup.coffee | MIT | aefcb7cc109f40f6133c30a017f5e3f1cfa79376 | 1,245 | https://github.com/mauricemach/coffeekup/blob/aefcb7cc109f40f6133c30a017f5e3f1cfa79376/lib/coffeekup.coffee | 108 | 129 |
mauricemach/coffeekup:lib/coffeekup.coffee:3:raw_corpus | raw_corpus | else code = ''
vars = []
`for(k in locals) {vars.push('var ' + k + ' = locals.' + k + ';')}`
scoped_template = new Function('locals', (vars.join '') + code)
@cache[template] = scoped_template if options.cache
scoped_template.call context, locals
buffer.pop() if buffer[buffer.length-1] ... | CoffeeScript | mauricemach/coffeekup | lib/coffeekup.coffee | MIT | 6f1636eef797d55ad1ac3b65d5854c9d417cfa2b | 1,245 | https://github.com/mauricemach/coffeekup/blob/6f1636eef797d55ad1ac3b65d5854c9d417cfa2b/lib/coffeekup.coffee | 108 | 131 | ||
mauricemach/coffeekup:lib/coffeekup.coffee:3:completion | completion | else code = ''
vars = []
`for(k in locals) {vars.push('var ' + k + ' = locals.' + k + ';')}`
scoped_template = new Function('locals', (vars.join '') + code)
@cache[template] = scoped_template if options.cache
scoped_template.call context, locals
buffer.pop() if buffer[buffer.length-1] ... | root.version = CoffeeKup.version
unless browser
root.render = (template, options) ->
CoffeeKup.render(template, options)
root.adapters = {}
root.adapters.simple = (template, data) ->
CoffeeKup.render(template, {context: data})
root.adapters.meryl = root.adapters.simple | CoffeeScript | CoffeeScript | mauricemach/coffeekup | lib/coffeekup.coffee | MIT | 6f1636eef797d55ad1ac3b65d5854c9d417cfa2b | 1,245 | https://github.com/mauricemach/coffeekup/blob/6f1636eef797d55ad1ac3b65d5854c9d417cfa2b/lib/coffeekup.coffee | 108 | 131 |
mauricemach/coffeekup:lib/coffeekup.coffee:2:raw_corpus | raw_corpus | text CoffeeKup.doctypes[type]
text "\n" unless options.compact
comment = (cmt) ->
text "<!--#{cmt}-->"
tag = (name, opts) ->
text "<#{name}"
for o in opts
text render_attrs(o) if typeof o is 'object'
if name in CoffeeKup.self_closing
text ' />'
else
... | CoffeeScript | mauricemach/coffeekup | lib/coffeekup.coffee | MIT | 6497b14a1e65f8c3ed6c2ecefaebc2529a1de0ae | 1,245 | https://github.com/mauricemach/coffeekup/blob/6497b14a1e65f8c3ed6c2ecefaebc2529a1de0ae/lib/coffeekup.coffee | 58 | 107 | ||
mauricemach/coffeekup:lib/coffeekup.coffee:2:completion | completion | text CoffeeKup.doctypes[type]
text "\n" unless options.compact
comment = (cmt) ->
text "<!--#{cmt}-->"
tag = (name, opts) ->
text "<#{name}"
for o in opts
text render_attrs(o) if typeof o is 'object'
if name in CoffeeKup.self_closing
text ' />'
else
... | null
coffeescript = (code) ->
tag 'script', "(#{code})();"
locals.text = text
locals.render_attrs = render_attrs
locals.doctype = doctype
locals.comment = comment
locals.tag = tag
locals.coffeescript = coffeescript
for t in @tags
locals[t] = -> tag t, arguments
if op... | CoffeeScript | CoffeeScript | mauricemach/coffeekup | lib/coffeekup.coffee | MIT | 6497b14a1e65f8c3ed6c2ecefaebc2529a1de0ae | 1,245 | https://github.com/mauricemach/coffeekup/blob/6497b14a1e65f8c3ed6c2ecefaebc2529a1de0ae/lib/coffeekup.coffee | 58 | 107 |
mauricemach/coffeekup:lib/coffeekup.coffee:3:raw_corpus | raw_corpus | else
code = @unwrap(template)
else
code = ''
vars = []
# for k, v of locals
# vars.push "var #{k} = locals.#{k};"
`for(k in locals) {vars.push('var ' + k + ' = locals.' + k + ';')}`
scoped_template = new Function('locals', (vars.join '') + code)
@cache[... | CoffeeScript | mauricemach/coffeekup | lib/coffeekup.coffee | MIT | 6497b14a1e65f8c3ed6c2ecefaebc2529a1de0ae | 1,245 | https://github.com/mauricemach/coffeekup/blob/6497b14a1e65f8c3ed6c2ecefaebc2529a1de0ae/lib/coffeekup.coffee | 108 | 137 | ||
mauricemach/coffeekup:lib/coffeekup.coffee:3:completion | completion | else
code = @unwrap(template)
else
code = ''
vars = []
# for k, v of locals
# vars.push "var #{k} = locals.#{k};"
`for(k in locals) {vars.push('var ' + k + ' = locals.' + k + ';')}`
scoped_template = new Function('locals', (vars.join '') + code)
@cache[... | buffer.join ''
root.CoffeeKup = CoffeeKup
root.version = CoffeeKup.version
unless browser
root.render = (template, options) ->
CoffeeKup.render(template, options)
root.adapters = {}
root.adapters.simple = (template, data) ->
CoffeeKup.render(template, {context: data})
root.adapters.meryl = root.ada... | CoffeeScript | CoffeeScript | mauricemach/coffeekup | lib/coffeekup.coffee | MIT | 6497b14a1e65f8c3ed6c2ecefaebc2529a1de0ae | 1,245 | https://github.com/mauricemach/coffeekup/blob/6497b14a1e65f8c3ed6c2ecefaebc2529a1de0ae/lib/coffeekup.coffee | 108 | 137 |
mauricemach/coffeekup:lib/coffeekup.coffee:1:raw_corpus | raw_corpus | class CoffeeKup
@version: '0.1.6'
@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 "-//W3... | CoffeeScript | mauricemach/coffeekup | lib/coffeekup.coffee | MIT | 4c7a0f8ac05fe1109928bed64e4a4847532dabb4 | 1,245 | https://github.com/mauricemach/coffeekup/blob/4c7a0f8ac05fe1109928bed64e4a4847532dabb4/lib/coffeekup.coffee | 8 | 57 | ||
mauricemach/coffeekup:lib/coffeekup.coffee:1:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
class CoffeeKup
@version: '0.1.6'
@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... | var CoffeeKup;
CoffeeKup = (function() {
class CoffeeKup {
static unwrap(code) {
code = String(code);
if (code.search(/^(\s)*function/ > -1)) {
code = code.replace(/^(\s)*function(\s)*\(\)(\s)*\{/, '');
return code = code.replace(/\}(\s)*$/, '');
}
}
static render(templ... | CoffeeScript | JavaScript | mauricemach/coffeekup | lib/coffeekup.coffee | MIT | 4c7a0f8ac05fe1109928bed64e4a4847532dabb4 | 1,245 | https://github.com/mauricemach/coffeekup/blob/4c7a0f8ac05fe1109928bed64e4a4847532dabb4/lib/coffeekup.coffee | 8 | 57 |
mauricemach/coffeekup:lib/coffeekup.coffee:1:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var CoffeeKup;
CoffeeKup = (function() {
class CoffeeKup {
static unwrap(code) {
code = String(code);
if (code.search(/^(\s)*function/ > -1)) {
code = code.replace(/^(\s)*function(\s)*\(\)(\s)*\{/, '');
return code = code.replace(... | class CoffeeKup
@version: '0.1.6'
@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 "-//W3... | JavaScript | CoffeeScript | mauricemach/coffeekup | lib/coffeekup.coffee | MIT | 4c7a0f8ac05fe1109928bed64e4a4847532dabb4 | 1,245 | https://github.com/mauricemach/coffeekup/blob/4c7a0f8ac05fe1109928bed64e4a4847532dabb4/lib/coffeekup.coffee | 8 | 57 |
mauricemach/coffeekup:lib/coffeekup.coffee:1:completion | completion | class CoffeeKup
@version: '0.1.6'
@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 "-//W3... | @cache: {}
@render: (template, options) ->
options ?= {}
options.cache ?= off
options.compact ?= off
buffer = []
context = options.context or {}
locals = options.locals or {}
if options.cache and @cache[template]?
scoped_template = @cache[template]
else
switch typeof tem... | CoffeeScript | CoffeeScript | mauricemach/coffeekup | lib/coffeekup.coffee | MIT | 4c7a0f8ac05fe1109928bed64e4a4847532dabb4 | 1,245 | https://github.com/mauricemach/coffeekup/blob/4c7a0f8ac05fe1109928bed64e4a4847532dabb4/lib/coffeekup.coffee | 8 | 57 |
mauricemach/coffeekup:lib/coffeekup.coffee:2:raw_corpus | raw_corpus | scoped_template = Function('locals', "with(locals) {#{code}}")
@cache[template] = scoped_template if options.cache
if locals.body?
context.body = locals.body
delete locals.body
text = (txt) -> buffer.push txt; null
render_attrs = (obj) ->
str = ''
for k, v of obj
str... | CoffeeScript | mauricemach/coffeekup | lib/coffeekup.coffee | MIT | 4c7a0f8ac05fe1109928bed64e4a4847532dabb4 | 1,245 | https://github.com/mauricemach/coffeekup/blob/4c7a0f8ac05fe1109928bed64e4a4847532dabb4/lib/coffeekup.coffee | 58 | 107 | ||
mauricemach/coffeekup:lib/coffeekup.coffee:2:completion | completion | scoped_template = Function('locals', "with(locals) {#{code}}")
@cache[template] = scoped_template if options.cache
if locals.body?
context.body = locals.body
delete locals.body
text = (txt) -> buffer.push txt; null
render_attrs = (obj) ->
str = ''
for k, v of obj
str... | for o in opts
text render_attrs(o) if typeof o is 'object'
if name in CoffeeKup.self_closing
text ' />'
else
text '>'
for o in opts
switch typeof o
when 'function'
result = o.call(context)
text result if typeof result is 'str... | CoffeeScript | CoffeeScript | mauricemach/coffeekup | lib/coffeekup.coffee | MIT | 4c7a0f8ac05fe1109928bed64e4a4847532dabb4 | 1,245 | https://github.com/mauricemach/coffeekup/blob/4c7a0f8ac05fe1109928bed64e4a4847532dabb4/lib/coffeekup.coffee | 58 | 107 |
mauricemach/coffeekup:lib/coffeekup.coffee:3:raw_corpus | raw_corpus | locals.comment = comment
locals.tag = tag
locals.coffeescript = coffeescript
for t in @tags
locals[t] = (opts...) -> tag t, opts
scoped_template.call context, locals
buffer.pop() if buffer[buffer.length-1] is "\n"
buffer.join ''
root.CoffeeKup = CoffeeKup
root.version = CoffeeKup.versio... | CoffeeScript | mauricemach/coffeekup | lib/coffeekup.coffee | MIT | 4c7a0f8ac05fe1109928bed64e4a4847532dabb4 | 1,245 | https://github.com/mauricemach/coffeekup/blob/4c7a0f8ac05fe1109928bed64e4a4847532dabb4/lib/coffeekup.coffee | 108 | 131 | ||
mauricemach/coffeekup:lib/coffeekup.coffee:3:completion | completion | locals.comment = comment
locals.tag = tag
locals.coffeescript = coffeescript
for t in @tags
locals[t] = (opts...) -> tag t, opts
scoped_template.call context, locals
buffer.pop() if buffer[buffer.length-1] is "\n"
buffer.join ''
root.CoffeeKup = CoffeeKup | root.version = CoffeeKup.version
unless browser
root.render = (template, options) ->
CoffeeKup.render(template, options)
root.adapters = {}
root.adapters.simple = (template, data) ->
CoffeeKup.render(template, {context: data})
root.adapters.meryl = root.adapters.simple | CoffeeScript | CoffeeScript | mauricemach/coffeekup | lib/coffeekup.coffee | MIT | 4c7a0f8ac05fe1109928bed64e4a4847532dabb4 | 1,245 | https://github.com/mauricemach/coffeekup/blob/4c7a0f8ac05fe1109928bed64e4a4847532dabb4/lib/coffeekup.coffee | 108 | 131 |
mauricemach/coffeekup:lib/coffeekup.coffee:1:raw_corpus | raw_corpus | class CoffeeKup
@version: '0.1.5'
@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 "-//W3... | CoffeeScript | mauricemach/coffeekup | lib/coffeekup.coffee | MIT | fe1357dd9b0f6620f728458dad1a59a534d694e2 | 1,245 | https://github.com/mauricemach/coffeekup/blob/fe1357dd9b0f6620f728458dad1a59a534d694e2/lib/coffeekup.coffee | 8 | 57 | ||
mauricemach/coffeekup:lib/coffeekup.coffee:1:completion | completion | class CoffeeKup
@version: '0.1.5'
@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 "-//W3... | @render: (template, options) ->
options ?= {}
options.cache ?= off
if options.cache is off or not @inst?
@inst = new CoffeeKup
switch typeof template
when 'function'
code = @unwrap(template)
when 'string'
if coffee?
code = coffee.compile String(te... | CoffeeScript | CoffeeScript | mauricemach/coffeekup | lib/coffeekup.coffee | MIT | fe1357dd9b0f6620f728458dad1a59a534d694e2 | 1,245 | https://github.com/mauricemach/coffeekup/blob/fe1357dd9b0f6620f728458dad1a59a534d694e2/lib/coffeekup.coffee | 8 | 57 |
mauricemach/coffeekup:lib/coffeekup.coffee:2:raw_corpus | raw_corpus | @inst.body = locals.body
delete locals.body
locals.doctype = @inst.doctype
locals.comment = @inst.comment
locals.text = @inst.text
locals.tag = @inst.tag
locals.coffeescript = @inst.coffeescript
for t in @tags
locals[t] = (opts...) -> @tag t, opts
b = @inst.buffer = []
@fun... | CoffeeScript | mauricemach/coffeekup | lib/coffeekup.coffee | MIT | fe1357dd9b0f6620f728458dad1a59a534d694e2 | 1,245 | https://github.com/mauricemach/coffeekup/blob/fe1357dd9b0f6620f728458dad1a59a534d694e2/lib/coffeekup.coffee | 58 | 107 | ||
mauricemach/coffeekup:lib/coffeekup.coffee:2:completion | completion | @inst.body = locals.body
delete locals.body
locals.doctype = @inst.doctype
locals.comment = @inst.comment
locals.text = @inst.text
locals.tag = @inst.tag
locals.coffeescript = @inst.coffeescript
for t in @tags
locals[t] = (opts...) -> @tag t, opts
b = @inst.buffer = []
@fun... | @text ' />'
else
@text '>'
for o in opts
switch typeof o
when 'function'
result = o.call(@)
@text result if typeof result is 'string'
when 'string' then @text o
@text "</#{name}>"
@text "\n" unless @compact
null
render_attrs: (obj) -... | CoffeeScript | CoffeeScript | mauricemach/coffeekup | lib/coffeekup.coffee | MIT | fe1357dd9b0f6620f728458dad1a59a534d694e2 | 1,245 | https://github.com/mauricemach/coffeekup/blob/fe1357dd9b0f6620f728458dad1a59a534d694e2/lib/coffeekup.coffee | 58 | 107 |
mauricemach/coffeekup:lib/coffeekup.coffee:3:raw_corpus | raw_corpus | comment: (text) =>
@text "<!--#{text}-->"
coffeescript: (func) ->
@script ->
code = String(func)
@text "(#{code})();"
root.CoffeeKup = CoffeeKup
root.version = CoffeeKup.version
unless browser
root.render = (template, options) ->
CoffeeKup.render(template, options)
root.adapters = {}
... | CoffeeScript | mauricemach/coffeekup | lib/coffeekup.coffee | MIT | fe1357dd9b0f6620f728458dad1a59a534d694e2 | 1,245 | https://github.com/mauricemach/coffeekup/blob/fe1357dd9b0f6620f728458dad1a59a534d694e2/lib/coffeekup.coffee | 108 | 128 | ||
mauricemach/coffeekup:lib/coffeekup.coffee:3:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
comment: (text) =>
@text "<!--#{text}-->"
coffeescript: (func) ->
@script ->
code = String(func)
@text "(#{code})();"
root.CoffeeKup = CoffeeKup
root.version = CoffeeKup.version
unless browser
root.render = (template, options) ->
Co... | ({
comment: (text) => {
return this.text(`<!--${text}-->`);
},
coffeescript: function(func) {
return this.script(function() {
var code;
code = String(func);
return this.text(`(${code})();`);
});
}
});
root.CoffeeKup = CoffeeKup;
root.version = CoffeeKup.version;
if (!browser) {
... | CoffeeScript | JavaScript | mauricemach/coffeekup | lib/coffeekup.coffee | MIT | fe1357dd9b0f6620f728458dad1a59a534d694e2 | 1,245 | https://github.com/mauricemach/coffeekup/blob/fe1357dd9b0f6620f728458dad1a59a534d694e2/lib/coffeekup.coffee | 108 | 128 |
mauricemach/coffeekup:lib/coffeekup.coffee:3:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
({
comment: (text) => {
return this.text(`<!--${text}-->`);
},
coffeescript: function(func) {
return this.script(function() {
var code;
code = String(func);
return this.text(`(${code})();`);
});
}
});
root.CoffeeKup = CoffeeKu... | comment: (text) =>
@text "<!--#{text}-->"
coffeescript: (func) ->
@script ->
code = String(func)
@text "(#{code})();"
root.CoffeeKup = CoffeeKup
root.version = CoffeeKup.version
unless browser
root.render = (template, options) ->
CoffeeKup.render(template, options)
root.adapters = {}
... | JavaScript | CoffeeScript | mauricemach/coffeekup | lib/coffeekup.coffee | MIT | fe1357dd9b0f6620f728458dad1a59a534d694e2 | 1,245 | https://github.com/mauricemach/coffeekup/blob/fe1357dd9b0f6620f728458dad1a59a534d694e2/lib/coffeekup.coffee | 108 | 128 |
mauricemach/coffeekup:lib/coffeekup.coffee:3:completion | completion | comment: (text) =>
@text "<!--#{text}-->"
coffeescript: (func) ->
@script ->
code = String(func)
@text "(#{code})();"
root.CoffeeKup = CoffeeKup
root.version = CoffeeKup.version | unless browser
root.render = (template, options) ->
CoffeeKup.render(template, options)
root.adapters = {}
root.adapters.simple = (template, data) ->
CoffeeKup.render(template, {context: data})
root.adapters.meryl = root.adapters.simple | CoffeeScript | CoffeeScript | mauricemach/coffeekup | lib/coffeekup.coffee | MIT | fe1357dd9b0f6620f728458dad1a59a534d694e2 | 1,245 | https://github.com/mauricemach/coffeekup/blob/fe1357dd9b0f6620f728458dad1a59a534d694e2/lib/coffeekup.coffee | 108 | 128 |
mauricemach/coffeekup:lib/coffeekup.coffee:1:raw_corpus | raw_corpus | class CoffeeKup
@version: '0.1.4'
@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 "-//W3... | CoffeeScript | mauricemach/coffeekup | lib/coffeekup.coffee | MIT | 13323a7ba647f9b4d2a477b15ebdd725b09d65dd | 1,245 | https://github.com/mauricemach/coffeekup/blob/13323a7ba647f9b4d2a477b15ebdd725b09d65dd/lib/coffeekup.coffee | 8 | 57 | ||
mauricemach/coffeekup:lib/coffeekup.coffee:1:completion | completion | class CoffeeKup
@version: '0.1.4'
@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 "-//W3... | @render: (template, options) ->
options ?= {}
options.cache ?= off
if options.cache is off or not @inst?
@inst = new CoffeeKup
switch typeof template
when 'function'
code = @unwrap(template)
when 'string'
if coffee?
code = coffee.compile String(te... | CoffeeScript | CoffeeScript | mauricemach/coffeekup | lib/coffeekup.coffee | MIT | 13323a7ba647f9b4d2a477b15ebdd725b09d65dd | 1,245 | https://github.com/mauricemach/coffeekup/blob/13323a7ba647f9b4d2a477b15ebdd725b09d65dd/lib/coffeekup.coffee | 8 | 57 |
mauricemach/coffeekup:lib/coffeekup.coffee:3:raw_corpus | raw_corpus | comment: (text) =>
@text "<!--#{text}-->"
coffeescript: (func) ->
@script ->
code = String(func)
@text "(#{code})();"
root.CoffeeKup = CoffeeKup
root.version = CoffeeKup.version | CoffeeScript | mauricemach/coffeekup | lib/coffeekup.coffee | MIT | 13323a7ba647f9b4d2a477b15ebdd725b09d65dd | 1,245 | https://github.com/mauricemach/coffeekup/blob/13323a7ba647f9b4d2a477b15ebdd725b09d65dd/lib/coffeekup.coffee | 108 | 117 | ||
mauricemach/coffeekup:lib/coffeekup.coffee:3:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
comment: (text) =>
@text "<!--#{text}-->"
coffeescript: (func) ->
@script ->
code = String(func)
@text "(#{code})();"
root.CoffeeKup = CoffeeKup
root.version = CoffeeKup.version
``` | ({
comment: (text) => {
return this.text(`<!--${text}-->`);
},
coffeescript: function(func) {
return this.script(function() {
var code;
code = String(func);
return this.text(`(${code})();`);
});
}
});
root.CoffeeKup = CoffeeKup;
root.version = CoffeeKup.version; | CoffeeScript | JavaScript | mauricemach/coffeekup | lib/coffeekup.coffee | MIT | 13323a7ba647f9b4d2a477b15ebdd725b09d65dd | 1,245 | https://github.com/mauricemach/coffeekup/blob/13323a7ba647f9b4d2a477b15ebdd725b09d65dd/lib/coffeekup.coffee | 108 | 117 |
mauricemach/coffeekup:lib/coffeekup.coffee:3:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
({
comment: (text) => {
return this.text(`<!--${text}-->`);
},
coffeescript: function(func) {
return this.script(function() {
var code;
code = String(func);
return this.text(`(${code})();`);
});
}
});
root.CoffeeKup = CoffeeKu... | comment: (text) =>
@text "<!--#{text}-->"
coffeescript: (func) ->
@script ->
code = String(func)
@text "(#{code})();"
root.CoffeeKup = CoffeeKup
root.version = CoffeeKup.version | JavaScript | CoffeeScript | mauricemach/coffeekup | lib/coffeekup.coffee | MIT | 13323a7ba647f9b4d2a477b15ebdd725b09d65dd | 1,245 | https://github.com/mauricemach/coffeekup/blob/13323a7ba647f9b4d2a477b15ebdd725b09d65dd/lib/coffeekup.coffee | 108 | 117 |
mauricemach/coffeekup:lib/coffeekup.coffee:3:completion | completion | comment: (text) =>
@text "<!--#{text}-->"
coffeescript: (func) ->
@script -> | code = String(func)
@text "(#{code})();"
root.CoffeeKup = CoffeeKup
root.version = CoffeeKup.version | CoffeeScript | CoffeeScript | mauricemach/coffeekup | lib/coffeekup.coffee | MIT | 13323a7ba647f9b4d2a477b15ebdd725b09d65dd | 1,245 | https://github.com/mauricemach/coffeekup/blob/13323a7ba647f9b4d2a477b15ebdd725b09d65dd/lib/coffeekup.coffee | 108 | 117 |
mauricemach/coffeekup:lib/coffeekup.coffee:2:raw_corpus | raw_corpus | @inst.body = locals.body
delete locals.body
locals.doctype = @inst.doctype
locals.comment = @inst.comment
locals.text = @inst.text
locals.tag = @inst.tag
locals.coffeescript = @inst.coffeescript
for t in @tags
locals[t] = (opts...) -> @tag t, opts
b = @inst.buffer = []
@fun... | CoffeeScript | mauricemach/coffeekup | lib/coffeekup.coffee | MIT | 734790add8751d1ad193825ce6fa47ed4cd27a52 | 1,245 | https://github.com/mauricemach/coffeekup/blob/734790add8751d1ad193825ce6fa47ed4cd27a52/lib/coffeekup.coffee | 58 | 107 | ||
mauricemach/coffeekup:lib/coffeekup.coffee:2:completion | completion | @inst.body = locals.body
delete locals.body
locals.doctype = @inst.doctype
locals.comment = @inst.comment
locals.text = @inst.text
locals.tag = @inst.tag
locals.coffeescript = @inst.coffeescript
for t in @tags
locals[t] = (opts...) -> @tag t, opts
b = @inst.buffer = []
@fun... | @text ' />'
else
@text '>'
for o in opts
switch typeof o
when 'function'
result = o.call(@)
@text result.toString() if result is 'string'
when 'string' then @text o
@text "</#{name}>"
@text "\n" unless @compact
null
render_attrs: (ob... | CoffeeScript | CoffeeScript | mauricemach/coffeekup | lib/coffeekup.coffee | MIT | 734790add8751d1ad193825ce6fa47ed4cd27a52 | 1,245 | https://github.com/mauricemach/coffeekup/blob/734790add8751d1ad193825ce6fa47ed4cd27a52/lib/coffeekup.coffee | 58 | 107 |
mauricemach/coffeekup:lib/coffeekup.coffee:1:raw_corpus | raw_corpus | class CoffeeKup
@version: '0.1.4'
@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 "-//W3... | CoffeeScript | mauricemach/coffeekup | lib/coffeekup.coffee | MIT | 61edd4c83a6320265c9750170fe7d903a8cb26df | 1,245 | https://github.com/mauricemach/coffeekup/blob/61edd4c83a6320265c9750170fe7d903a8cb26df/lib/coffeekup.coffee | 8 | 57 | ||
mauricemach/coffeekup:lib/coffeekup.coffee:1:completion | completion | class CoffeeKup
@version: '0.1.4'
@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 "-//W3... | @render: (template, options) ->
options ?= {}
options.cache ?= off
if options.cache is off or not @inst?
@inst = new CoffeeKup
switch typeof template
when 'function'
code = @unwrap(template)
when 'string'
if coffee?
code = coffee.compile String(te... | CoffeeScript | CoffeeScript | mauricemach/coffeekup | lib/coffeekup.coffee | MIT | 61edd4c83a6320265c9750170fe7d903a8cb26df | 1,245 | https://github.com/mauricemach/coffeekup/blob/61edd4c83a6320265c9750170fe7d903a8cb26df/lib/coffeekup.coffee | 8 | 57 |
mauricemach/coffeekup:lib/coffeekup.coffee:1:raw_corpus | raw_corpus | class CoffeeKup
@version: '0.1.4'
@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 "-//W3... | CoffeeScript | mauricemach/coffeekup | lib/coffeekup.coffee | MIT | 22ce0f1618f4c4f9a072e365b2bad6a8df9e1b2c | 1,245 | https://github.com/mauricemach/coffeekup/blob/22ce0f1618f4c4f9a072e365b2bad6a8df9e1b2c/lib/coffeekup.coffee | 8 | 57 | ||
mauricemach/coffeekup:lib/coffeekup.coffee:1:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
class CoffeeKup
@version: '0.1.4'
@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... | var CoffeeKup;
CoffeeKup = (function() {
class CoffeeKup {
static unwrap(code) {
code = String(code);
if (code.search(/^(\s)*function/ > -1)) {
code = code.replace(/^(\s)*function(\s)*\(\)(\s)*\{/, '');
return code = code.replace(/\}(\s)*$/, '');
}
}
static render(templ... | CoffeeScript | JavaScript | mauricemach/coffeekup | lib/coffeekup.coffee | MIT | 22ce0f1618f4c4f9a072e365b2bad6a8df9e1b2c | 1,245 | https://github.com/mauricemach/coffeekup/blob/22ce0f1618f4c4f9a072e365b2bad6a8df9e1b2c/lib/coffeekup.coffee | 8 | 57 |
mauricemach/coffeekup:lib/coffeekup.coffee:1:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var CoffeeKup;
CoffeeKup = (function() {
class CoffeeKup {
static unwrap(code) {
code = String(code);
if (code.search(/^(\s)*function/ > -1)) {
code = code.replace(/^(\s)*function(\s)*\(\)(\s)*\{/, '');
return code = code.replace(... | class CoffeeKup
@version: '0.1.4'
@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 "-//W3... | JavaScript | CoffeeScript | mauricemach/coffeekup | lib/coffeekup.coffee | MIT | 22ce0f1618f4c4f9a072e365b2bad6a8df9e1b2c | 1,245 | https://github.com/mauricemach/coffeekup/blob/22ce0f1618f4c4f9a072e365b2bad6a8df9e1b2c/lib/coffeekup.coffee | 8 | 57 |
mauricemach/coffeekup:lib/coffeekup.coffee:1:completion | completion | class CoffeeKup
@version: '0.1.4'
@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 "-//W3... | @render: (template, options) ->
options ?= {}
options.cache ?= off
if options?.cache is off or not @inst?
@inst = new CoffeeKup
switch typeof template
when 'function'
code = @unwrap(template)
when 'string'
if coffee?
code = coffee.compile String(t... | CoffeeScript | CoffeeScript | mauricemach/coffeekup | lib/coffeekup.coffee | MIT | 22ce0f1618f4c4f9a072e365b2bad6a8df9e1b2c | 1,245 | https://github.com/mauricemach/coffeekup/blob/22ce0f1618f4c4f9a072e365b2bad6a8df9e1b2c/lib/coffeekup.coffee | 8 | 57 |
mauricemach/coffeekup:lib/coffeekup.coffee:2:raw_corpus | raw_corpus | delete locals.body
locals.doctype = @inst.doctype
locals.comment = @inst.comment
locals.text = @inst.text
locals.tag = @inst.tag
locals.coffeescript = @inst.coffeescript
for t in @tags
locals[t] = (opts...) -> @tag t, opts
b = @inst.buffer = []
@func.call @inst, locals
b.pop(... | CoffeeScript | mauricemach/coffeekup | lib/coffeekup.coffee | MIT | 22ce0f1618f4c4f9a072e365b2bad6a8df9e1b2c | 1,245 | https://github.com/mauricemach/coffeekup/blob/22ce0f1618f4c4f9a072e365b2bad6a8df9e1b2c/lib/coffeekup.coffee | 58 | 107 | ||
mauricemach/coffeekup:lib/coffeekup.coffee:2:completion | completion | delete locals.body
locals.doctype = @inst.doctype
locals.comment = @inst.comment
locals.text = @inst.text
locals.tag = @inst.tag
locals.coffeescript = @inst.coffeescript
for t in @tags
locals[t] = (opts...) -> @tag t, opts
b = @inst.buffer = []
@func.call @inst, locals
b.pop(... | @text '>'
for o in opts
switch typeof o
when 'function'
result = o.call(@)
@text result.toString() if result is 'string'
when 'string' then @text o
@text "</#{name}>"
@text "\n" unless @compact
null
render_attrs: (obj) ->
str = ''
for ... | CoffeeScript | CoffeeScript | mauricemach/coffeekup | lib/coffeekup.coffee | MIT | 22ce0f1618f4c4f9a072e365b2bad6a8df9e1b2c | 1,245 | https://github.com/mauricemach/coffeekup/blob/22ce0f1618f4c4f9a072e365b2bad6a8df9e1b2c/lib/coffeekup.coffee | 58 | 107 |
mauricemach/coffeekup:lib/coffeekup.coffee:3:raw_corpus | raw_corpus | @text "<!--#{text}-->"
coffeescript: (func) ->
@script ->
code = String(func)
@text "(#{code})();"
root.CoffeeKup = CoffeeKup
root.version = CoffeeKup.version | CoffeeScript | mauricemach/coffeekup | lib/coffeekup.coffee | MIT | 22ce0f1618f4c4f9a072e365b2bad6a8df9e1b2c | 1,245 | https://github.com/mauricemach/coffeekup/blob/22ce0f1618f4c4f9a072e365b2bad6a8df9e1b2c/lib/coffeekup.coffee | 108 | 116 | ||
mauricemach/coffeekup:lib/coffeekup.coffee:3:completion | completion | @text "<!--#{text}-->"
coffeescript: (func) ->
@script -> | code = String(func)
@text "(#{code})();"
root.CoffeeKup = CoffeeKup
root.version = CoffeeKup.version | CoffeeScript | CoffeeScript | mauricemach/coffeekup | lib/coffeekup.coffee | MIT | 22ce0f1618f4c4f9a072e365b2bad6a8df9e1b2c | 1,245 | https://github.com/mauricemach/coffeekup/blob/22ce0f1618f4c4f9a072e365b2bad6a8df9e1b2c/lib/coffeekup.coffee | 108 | 116 |
mauricemach/coffeekup:lib/coffeekup.coffee:1:raw_corpus | raw_corpus | class CoffeeKup
@version: '0.1.3'
@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 "-//W3... | CoffeeScript | mauricemach/coffeekup | lib/coffeekup.coffee | MIT | 507a365de6007ffccce9f142296a020e455dd6cd | 1,245 | https://github.com/mauricemach/coffeekup/blob/507a365de6007ffccce9f142296a020e455dd6cd/lib/coffeekup.coffee | 5 | 54 | ||
mauricemach/coffeekup:lib/coffeekup.coffee:1:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
class CoffeeKup
@version: '0.1.3'
@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... | var CoffeeKup;
CoffeeKup = (function() {
class CoffeeKup {
static render(template, options) {
var code, context, k, locals, v;
if (options == null) {
options = {};
}
if (options.cache == null) {
options.cache = false;
}
if ((options != null ? options.cache : vo... | CoffeeScript | JavaScript | mauricemach/coffeekup | lib/coffeekup.coffee | MIT | 507a365de6007ffccce9f142296a020e455dd6cd | 1,245 | https://github.com/mauricemach/coffeekup/blob/507a365de6007ffccce9f142296a020e455dd6cd/lib/coffeekup.coffee | 5 | 54 |
mauricemach/coffeekup:lib/coffeekup.coffee:1:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var CoffeeKup;
CoffeeKup = (function() {
class CoffeeKup {
static render(template, options) {
var code, context, k, locals, v;
if (options == null) {
options = {};
}
if (options.cache == null) {
options.cache = false;
... | class CoffeeKup
@version: '0.1.3'
@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 "-//W3... | JavaScript | CoffeeScript | mauricemach/coffeekup | lib/coffeekup.coffee | MIT | 507a365de6007ffccce9f142296a020e455dd6cd | 1,245 | https://github.com/mauricemach/coffeekup/blob/507a365de6007ffccce9f142296a020e455dd6cd/lib/coffeekup.coffee | 5 | 54 |
mauricemach/coffeekup:lib/coffeekup.coffee:1:completion | completion | class CoffeeKup
@version: '0.1.3'
@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 "-//W3... | switch typeof template
when 'function'
code = String(template)
code = code.replace /^function \(\) \{/, ''
code = code.replace /\n( )*\}$/, ''
when 'string'
code = coffee.compile String(template), {'noWrap'}
else code = ''
@func = Function('locals', ... | CoffeeScript | CoffeeScript | mauricemach/coffeekup | lib/coffeekup.coffee | MIT | 507a365de6007ffccce9f142296a020e455dd6cd | 1,245 | https://github.com/mauricemach/coffeekup/blob/507a365de6007ffccce9f142296a020e455dd6cd/lib/coffeekup.coffee | 5 | 54 |
mauricemach/coffeekup:lib/coffeekup.coffee:2:raw_corpus | raw_corpus | for t in @tags
locals[t] = (opts...) -> @tag t, opts
b = @inst.buffer = []
@func.call @inst, locals
b.pop() if b[b.length-1] is "\n"
b.join ''
text: (txt) => @buffer.push txt; null
tag: (name, opts) =>
@text "<#{name}"
for o in opts
@text @render_attrs(o) if typeof o is 'objec... | CoffeeScript | mauricemach/coffeekup | lib/coffeekup.coffee | MIT | 507a365de6007ffccce9f142296a020e455dd6cd | 1,245 | https://github.com/mauricemach/coffeekup/blob/507a365de6007ffccce9f142296a020e455dd6cd/lib/coffeekup.coffee | 55 | 104 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.