Module: Rango::ExplicitRendering
Instance Method Summary collapse
-
#context ⇒ Object
def show context = Post.get(params) render “show.html”, context end.
- #render(template, context = Hash.new) ⇒ Object
-
#scope ⇒ Object
class Posts < Rango::Controller def scope Object.new end.
Instance Method Details
#context ⇒ Object
def show
context[:post] = Post.get(params[:id])
render "show.html", context
end
89 90 91 |
# File 'lib/rango/mixins/rendering.rb', line 89 def context @context ||= {request: self.request} end |
#render(template, context = Hash.new) ⇒ Object
62 63 64 |
# File 'lib/rango/mixins/rendering.rb', line 62 def render(template, context = Hash.new) super(template, self.scope, self.context.merge!(context)) end |
#scope ⇒ Object
class Posts < Rango::Controller
def scope
Object.new
end
def show
# you can't use @explicit
post = Post.get(params[:id])
render "post.html", post: post
end
end
Context for rendering templates This scope will be extended by same crucial methods from template mixin We are in scope of current controller by default
81 82 83 |
# File 'lib/rango/mixins/rendering.rb', line 81 def scope Object.new.extend(Rango::Helpers) end |