Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
"Inline" named helpers in HAML. You don't always need to **ck with .rb helpers or partials.
- # _hamlout is the secret sauce
- def test text, _hamlout
%h1 You gave me this:
-# the usual HAML structures can live here
- # remember I told of _hamlout? Kind of annoying, yeah, I know. But anyway.
- test "ohhai", _hamlout
- # notice that we don't =test, we call it as -test, or else you will see an unwanted 0
- # It's a quick hack right there. But I think, with some help of metaprogramming it is
- # possible to turn this into a more developed technique, saying goodbye to unnecessary
- # partials or creeping, out-of-context helpers.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment