Better partials with better-partials
The other week, Dan Croak pointed out better-partials to me. Hadn’t gotten a chance to play it until now.
The gist of better-partials is that it’s a syntactical sugar for render :partial
.
Here’s a typical haml snippet using a partial:
With better-partials, we can refactor it to:
This saves a little typing, and makes it a bit more clearer:
- You just say you want a partial, rather than to render a partial
- Automatically passes in options to
:locals
(with a few special exceptions)
There are a few other usages of better-partials, but I haven’t gotten to use them yet.
It’s not that big of a deal, but it seems like a nice little improvement to me.