giant robots smashing into other giant robots

We are thoughtbot. We make web & mobile apps.

Tagged:

Comments (View)

Sharing is caring

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