Sha256: c7410a9687ea1c9f24e38c968a7d819bba447e005261750e9560ceaf6c9618ae

Contents?: true

Size: 1 KB

Versions: 1

Compression:

Stored size: 1 KB

Contents

# encoding: utf-8

require "rango/mixins/render"

module Rango
  module ExplicitRendering
    include Rango::RenderMixin
    def render(template, locals = Hash.new)
      super(template, self.locals.merge!(locals))
    end

    # class Posts < Rango::Controller
    #   def context
    #     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 context will be extended by same crucial methods from template mixin
    # We are in context of current controller by default
    def context
      Object.new.extend(Rango::Helpers)
    end

    # def show
    #   locals[:post] = Post.get(params[:id])
    #   render "show.html", locals
    # end
    def locals
      @locals ||= {request: self.request}
    end
  end

  module ImplicitRendering
    def context
      self
    end

    def render(template)
      super template
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rango-0.1.1.2.6 lib/rango/mixins/rendering.rb