We're currently hiring Developers and Designers in Boston and New York.
Find out more and apply on our jobs page.

Aug 31 2009

Sharing is caring

Posted by dancroak

We recently described our experimental Cucumber directory convention.

Here’s another directory convention I’ve been using. Mise en place.

What’s wrong with this picture?

app/views/layouts/application.html.erb
app/views/layouts/_flashes.html.erb
app/views/layouts/_footer.html.erb
app/views/layouts/_header.html.erb
app/views/layouts/_javascript.html.erb
app/views/layouts/_navigation.html.erb

I want the layout directory to contain… layouts.

app/views/layouts/application.html.erb

Then I’ll use the shared directory for global partials.

app/views/shared/_flashes.html.erb
app/views/shared/_footer.html.erb
app/views/shared/_header.html.erb
app/views/shared/_javascript.html.erb
app/views/shared/_navigation.html.erb

This is recommended in the classic tome, Agile Web Development with Rails, but often overlooked.

In fact, Suspenders is currently out of line with this practice. I vote to change it! Yeas & Nays?

Bonus: when you extract a partial from a layout in rails.vim using :Rextract, it will automatically place the extracted partial into the shared directory.

It feels good to share.

Care bears

blog comments powered by Disqus