Skip to content

philcrissman/whiny_rendering

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WhinyRendering

WhinyRendering is a gem for Rails which provides a method for ActionView that displays information about the current controller, action, template being rendered, and a list of all the partials being used in that view as well.

It’s the result of a lot of conversations held around the office about how convenient it would be to have a list, on the page you are viewing in the browser, of the exact template (and partials!) that you are actually seeing rendered in the browser. The idea is to plug it in to a project that you may not be too familiar with, and to cut down on all that annoying searching through the controllers and/or views to figure out what is actually going on in the view.

This is a really early version. Feel free to send me feedback, ideas, pull requests, what-have-you.

Installing

Assuming you have gemcutter installed (gem install gemcutter):

gem install whiny_rendering

Or, if you prefer plugins:

script/plugin install git://github.com/philcrissman/whiny_rendering.git

(Haven’t tested it as a plugin, feedback welcomed.)

Usage

In your layout (probably application.html.(erb|haml)):

<%= whiny_rendering %>

This outputs a div containing the rendering information.

There are other formats available for use, however:

You can hide the div, and provide a unobtrusive link that developers can click to toggle its display (using prototype):

<%= whiny_rendering(:hidden) %>

Or, if you use jQuery:

<%= whiny_rendering(:hidden_jquery) %>

Using :hidden_prototype will also work, in the event that you’d like to be explicit.

You can also render it as an HTML comment rather than a div:

<%= whiny_rendering(:comment) %>

If you use haml, well; you know what to do.

You probably only want to see this in development mode, so you might rather:

<%= whiny_rendering if RAILS_ENV=="development" %>

… or something like that.

Right now, this will put a div with the relevant information at whatever spot in your template you placed the call to whiny_rendering. It’s completely unstyled, and there’s no whiny_rendering.css included with the gem (yet!), but the div has the id of #whiny_rendering (hope you weren’t using that for something already), so it is very easy to just add a few styles for this div to your default stylesheet.

Miscellany

Author’s homepage: philcrissman.com

About

A helper to make rails whiny about what it's rendering in the view

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages