Skip to content

Instantly share code, notes, and snippets.

@romac
Created November 11, 2011 23:34
Show Gist options
  • Save romac/1359669 to your computer and use it in GitHub Desktop.
Save romac/1359669 to your computer and use it in GitHub Desktop.
Generic renderer for Agora
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