diff --git a/README.md b/README.md index 67527f9..6843d66 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ class PostController < ApplicationController def index @posts = Post.order('created_at DESC') - respond_with(@posts) + respond_with(@posts) end end ``` @@ -69,12 +69,12 @@ The fact of compiling the template outside of any rendering context prevent us t The only places where you can actually used instance variables are into Proc (or lambda) or into custom node (because they are treated as Proc). ```ruby - # We reference the @posts varibles that will be used at rendering time - collection :@posts +# We reference the @posts varibles that will be used at rendering time +collection :@posts - # Here you can use directly the instance variable because it - # will be evaluated when rendering the object - node(:read) { |post| post.read_by?(@user) } +# Here you can use directly the instance variable because it +# will be evaluated when rendering the object +node(:read) { |post| post.read_by?(@user) } ``` The same rule applies for view helpers such as `current_user` @@ -98,19 +98,19 @@ collection :@users You can specify root label for the collection using hash or `:root` option ```ruby - collection :@posts, root: :articles - #is equivalent to - collection :@posts => :articles +collection :@posts, root: :articles +#is equivalent to +collection :@posts => :articles - # => { "articles" : [{...}, {...}] } +# => { "articles" : [{...}, {...}] } ``` There are rares cases when the template doesn't map directly to any object. In these cases, you can set data to false or skip data declaration altogether. ```ruby - object false - node(:some_count) { |_| @user.posts.count } - child(:@user) { attribute :name } +object false +node(:some_count) { |_| @user.posts.count } +child(:@user) { attribute :name } ``` ### Attributes / Methods @@ -118,14 +118,14 @@ There are rares cases when the template doesn't map directly to any object. In t Basic usage is to declared attributes to include in the response. These can be database attributes or any instance method. ```ruby - attributes :id, :title, :to_s +attributes :id, :title, :to_s ``` You can aliases these attributes in your response ```ruby - attributes title: :foo, to_s: :bar - # => { "foo" :