Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Rpbk (render partial by key) helps to manage which view to show depending on controller and action

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 test
Octocat-spinner-32 .gitignore
Octocat-spinner-32 Gemfile
Octocat-spinner-32 Rakefile
Octocat-spinner-32 readme
Octocat-spinner-32 rpbk.gemspec
readme
put configuration code into /config/initializers/rpbk.rb

Rpbk.setup.config do
  # set global keys
  set :error_messages => 'layouts/error_messages'
  set :assets         => 'layouts/assets'
  set :layout         => 'layouts/content'

  # create key group
  group :admin_group do
    set :assets => 'admin/home/assets'
    set :layout => 'admin/home/content'
  end

  # create keys for home controller
  controller :home do
    set :assets => 'home/assets'
    set :layout => 'home/content'
  end

  # set keys for admin/home controller and extend keys from :admin_group
  controller 'admin/home', :extend => :admin_group do

    # revrite :admin_group :assets key
    set :assets => 'admin/home/assets_special'

    # set keys for admin/home controller index action
    action :index do
      set :assets => 'admin/home/index/assets'
    end
    
    # extend :index2 action with keys from :index action in 'admin/home' controller
    action :index2, :extend => :index
  end

  # extend admin/categories with keys from admin/home controller
  controller 'admin/categories', :extend => 'admin/home'
end


you could use those keys in any view e.g.

<%= render :key => :assets %>
<%= render :key => :layout, :locals => {:tmp => 'blah'}, :other_default_render_parameters => true %>
Something went wrong with that request. Please try again.