Skip to content

Instantly share code, notes, and snippets.

@peterwmwong
Created August 3, 2011 05:34
Show Gist options
  • Save peterwmwong/1121973 to your computer and use it in GitHub Desktop.
Save peterwmwong/1121973 to your computer and use it in GitHub Desktop.
Cell Rendering: HTML-ish/HAML-ish (pick your poison)
# HAML-ish
define
render: (_)-> [
_ 'input#newtodo', type:'text', placeholder:'... new todo'
_ 'ul.todos',
for todo in window.todoList
_ 'li', todo
]
// HAML-ish
define({
render: function(_) { return [
_('#newtodo', {type:'text',placeholder:'... new todo'}),
_('ul.todos',
window.todoList.map(function(todo){
return _('li', todo);
})
)
]; }
});
# HTML-ish
define
render: (_)-> [
_ '<input id="newtodo" type="text" placeholder="... new todo">'
_ '<ul class="todos">',
for todo in window.todoList
_ '<li>', todo
]
// HTML-ish
define({
render: function(_) { return [
_('<input id="newtodo" type="text" placeholder="... new todo">'),
_('<ul class="todos">',
window.todoList.map(function(todo){
return _('<li>', todo);
})
)
];}
});
<!--
window.todoList = ['one','two','three','four'];
-->
<input id="newtodo" type="text" placeholder="... new todo"></input>
<ul class="todos">
<li>one</li>
<li>two</li>
<li>three</li>
<li>four</li>
</ul>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment