Skip to content

Commit

Permalink
Indentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Sofaer committed Sep 20, 2010
1 parent 61f3900 commit 7405749
Showing 1 changed file with 25 additions and 25 deletions.
50 changes: 25 additions & 25 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ I needed a logic-free template language, and Handlebars showed up in my RSS read
Presenters should return hashes if they intend to respond with OK. There should be no explicit render call inside them. They should be reusable as pieces of larger controller requests.

#WelcomeController
`require './lib/presenter'`
`class WelcomeController < Presenter`
` def index`
` {:text => "hello"}`
` end`
`end`
require './lib/presenter'
class WelcomeController < Presenter
def index
{:text => "hello"}
end
end

The view is a handlebars template
#app/views/welcome/index.html.bar
Expand All @@ -35,26 +35,26 @@ Here is some text: {{text}}
`{"text":"hello"}`

##Data for layouts:
`require './lib/presenter'`
`class ApplicationPresenter < Presenter`
` before_filter :layout_pieces`
` def layout_pieces`
` @layout_pieces = {:nav => "nav stuff"}`
` end`
`end`
require './lib/presenter'
class ApplicationPresenter < Presenter
before_filter :layout_pieces
def layout_pieces
@layout_pieces = {:nav => "nav stuff"}
end
end

##Complex Presenters
`require './lib/presenter'
class ComplexController < ApplicationPresenter
def index
{:main => main, :sidebar => sidebar}
end
def main
{:complexities => Complexity.all}
end
def sidebar
{:advertisements => Advertisement.for(current_user)
end
end`
require './lib/presenter
class ComplexController < ApplicationPresenter
def index
{:main => main, :sidebar => sidebar}
end
def main
{:complexities => Complexity.all}
end
def sidebar
{:advertisements => Advertisement.for(current_user)
end
end

As a side effect of this model, you can call main and sidebar as explicit JSON methods and get those pieces of data. This unifies your data presentation chain.

0 comments on commit 7405749

Please sign in to comment.