Skip to content

Instantly share code, notes, and snippets.

@insin
Created September 11, 2012 14:44
Show Gist options
  • Save insin/3699264 to your computer and use it in GitHub Desktop.
Save insin/3699264 to your computer and use it in GitHub Desktop.
var fs = require('fs')
, jade = require('jade')
var task = fs.readFileSync('task.jade')
var fn = jade.compile(fs.readFileSync('task.jade'), {pretty: true})
console.log(fn({
"settings" : {
"foo" : "low"
, "bar" : "high"
, "baz" : "low"
}
}))
h1 Settings
each value, name in settings
h2= name
for setting in ['low', 'high']
checked = setting === value
input(type='radio', name=name, value=setting, checked=checked)
| #{setting}
function anonymous(locals, attrs, escape, rethrow, merge) {
attrs = attrs || jade.attrs; escape = escape || jade.escape; rethrow = rethrow || jade.rethrow; merge = merge || jade.merge;
var buf = [];
with (locals || {}) {
var interp;
buf.push('<h1>Settings</h1>');
// iterate settings
;(function(){
if ('number' == typeof settings.length) {
for (var name = 0, $$l = settings.length; name < $$l; name++) {
var value = settings[name];
buf.push('<h2>');
var __val__ = name
buf.push(escape(null == __val__ ? "" : __val__));
buf.push('</h2>');
// iterate ['low', 'high']
;(function(){
if ('number' == typeof ['low', 'high'].length) {
for (var $index = 0, $$l = ['low', 'high'].length; $index < $$l; $index++) {
var setting = ['low', 'high'][$index];
var checked = (setting === value);
buf.push('<input');
buf.push(attrs({ 'type':('radio'), 'name':(name), 'value':(setting), 'checked':(checked) }, {"type":true,"name":true,"value":true,"checked":true}));
buf.push('/> ' + escape((interp = setting) == null ? '' : interp) + '');
}
} else {
for (var $index in ['low', 'high']) {
var setting = ['low', 'high'][$index];
var checked = (setting === value);
buf.push('<input');
buf.push(attrs({ 'type':('radio'), 'name':(name), 'value':(setting), 'checked':(checked) }, {"type":true,"name":true,"value":true,"checked":true}));
buf.push('/> ' + escape((interp = setting) == null ? '' : interp) + '');
}
}
}).call(this);
}
} else {
for (var name in settings) {
var value = settings[name];
buf.push('<h2>');
var __val__ = name
buf.push(escape(null == __val__ ? "" : __val__));
buf.push('</h2>');
// iterate ['low', 'high']
;(function(){
if ('number' == typeof ['low', 'high'].length) {
for (var $index = 0, $$l = ['low', 'high'].length; $index < $$l; $index++) {
var setting = ['low', 'high'][$index];
var checked = (setting === value);
buf.push('<input');
buf.push(attrs({ 'type':('radio'), 'name':(name), 'value':(setting), 'checked':(checked) }, {"type":true,"name":true,"value":true,"checked":true}));
buf.push('/> ' + escape((interp = setting) == null ? '' : interp) + '');
}
} else {
for (var $index in ['low', 'high']) {
var setting = ['low', 'high'][$index];
var checked = (setting === value);
buf.push('<input');
buf.push(attrs({ 'type':('radio'), 'name':(name), 'value':(setting), 'checked':(checked) }, {"type":true,"name":true,"value":true,"checked":true}));
buf.push('/> ' + escape((interp = setting) == null ? '' : interp) + '');
}
}
}).call(this);
}
}
}).call(this);
}
return buf.join("");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment