Created
September 11, 2012 14:44
-
-
Save insin/3699264 to your computer and use it in GitHub Desktop.
Response to https://gist.github.com/3696453
This file contains hidden or 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
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" | |
} | |
})) |
This file contains hidden or 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
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} |
This file contains hidden or 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
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