Created
October 28, 2011 16:18
-
-
Save alto/1322663 to your computer and use it in GitHub Desktop.
API DSL
This file contains 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
# places/index.api | |
@places.each do |place| | |
template('places/show', :place => place) # user shall be available as @user in the template | |
end | |
# places/show.api | |
object(@place) do | |
:name, # plain attribute | |
:address => address_for(@user), # helper used | |
:location => { # hash | |
:lat => 52.0, | |
:lng => 10.0 | |
}, | |
:category => :place_type, # renaming/mapping (@place.place_type exists) | |
:links => [ | |
{rel => 'self', :href => 'http://...'}, | |
{rel => 'full', :href => 'http://...'} | |
], | |
:host => template('users/show', :user => @place.host) # child_object | |
end | |
# users/show.api | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment