Skip to content

Instantly share code, notes, and snippets.

@nex3
Forked from queso/gist:16284
Created October 11, 2008 20:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nex3/16322 to your computer and use it in GitHub Desktop.
Save nex3/16322 to your computer and use it in GitHub Desktop.
# Haml blocks (and ERB blocks, for that matter) don't return their contents as a string.
# They append content directly to the template.
# Thus, you need to use #capture to get their content.
# I'm not sure why this worked with ERB; it's probably just an odd consequence of an implementation detail.
# Method
def submit(*args, &block)
@template.content_tag(:div, :class => "save_actions") do
super(*args) + @template.capture(&block)
end
end
# Calling Haml block
= f.submit "Sign up" do
- if @site.beta_invites?
or
= link_to "Request a beta invite", new_invite_path
### Output
or
<a href="/invites/new">Request a beta invite</a>
<div class="save_actions"><input id="user_submit" name="commit" type="submit" value="Sign up" /></div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment