Created
November 11, 2011 23:34
-
-
Save romac/1359669 to your computer and use it in GitHub Desktop.
Generic renderer for Agora
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
getRenderer = (records, template, prepare, insert) -> | |
render = (index = 0) -> | |
if index < records.length | |
record = records[records.length - 1 - index] | |
data = prepare record | |
context.render('templates/' + template + '.template', data ).then (node) -> | |
insert node | |
render index + 1 | |
category = {} | |
$threads = $ '.threads' | |
render = getRenderer( | |
category.threads, | |
'thread-summary', | |
(thread) -> thread.category = category; thread: thread, | |
(node) -> $threads.append node | |
) | |
render() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment