Created
November 16, 2010 20:18
-
-
Save mauricemach/702433 to your computer and use it in GitHub Desktop.
"Faking" partials with what we have in zappa today
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
get '/': -> | |
@items = [ | |
{name: 'coffeescript', url: 'http://coffeescript.org'} | |
{name: 'ruby', url: 'http://ruby-lang.org'} | |
{name: 'python', url: 'http://python.org'} | |
] | |
# I think helpers belong in the template's locals "namespace", | |
# but we cannot currently specify the template's locals in zappa. | |
@partial = partial | |
render 'default' | |
view -> | |
ul -> | |
for i in @items | |
text @partial 'item', i: i | |
partials = | |
item: -> | |
li -> a href: @i.url, -> @i.name | |
def partial: (key, data) -> | |
p = partials[key] | |
require('coffeekup').render p, context: data |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment