Skip to content

Instantly share code, notes, and snippets.

@genee19
Last active April 26, 2016 07:46
Show Gist options
  • Save genee19/74bb9b700af2e20bc6ba3e54e09e2a23 to your computer and use it in GitHub Desktop.
Save genee19/74bb9b700af2e20bc6ba3e54e09e2a23 to your computer and use it in GitHub Desktop.
"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
%pre=text
- # 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