Module: Rango::ExplicitRendering

Includes:
RenderMixin
Included in:
StackController
Defined in:
lib/rango/mixins/rendering.rb

Instance Method Summary collapse

Instance Method Details

#contextObject

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

#scopeObject

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