No commit activity in last 3 years
No release in over 3 years
DRYer rendering method for Padrino, mainly used for templates for controllers
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

 Project Readme

Padrino-Render-For

This is a dead-simple gem for those fed up with having to be redundant with a controller name in Padrino.

Installation

Add the following to your Gemfile:

gem 'padrino-render-for'

bundle install, and add the following to your app/app.rb file:

include Padrino::RenderFor

Done.

Usage

Let's start with a simple controller (this example builds off the prior example from padrino-relative)

MyApp.controller :users do
  get :sign_up, '/sign_up' do
    render_action
  end

  get :sign_in, '/sign_in' do
    render_action
  end

  get :list, '/' do
    render_for :all
  end

  get :show, ':id' do
    render_for :display
  end
end

Now, Padrino will look for the views app/views/users/sign_up, app/views/users/sign_in, app/views/users/all, and app/views/users/display (with whatever extension you use, such as .haml or .slim) respectively.

If you'd like, you can also pass in locals and options like you normally would, you can do render_for :action, :locals => {:foo => 'bar'}, since render_action is essentially an alias for render_for :action (If you'd like to render app/views/users/action, you can do render_for 'action', if such a thing were to ever come up)