Something I learned how to do in rails, but had a hard time replicating without it, is create a custom helper that accepts a block. I figured out how to write to the screen from the helper. @_out_buf is the name of the variable I needed.

# myview.erb
<% form("/login", :post) do %>
        <p>Username: <input type="text" name="username"></p>
        <p>Password: <input type="password" name="password"></p>
<% end %>

# helpers.rb
def form(url, method, &block)
  @_out_buf << "<form action='#{url}' method='post'>"
  @_out_buf << "<input type='hidden' name='_method' value='#{method}'>"
  yield
  @_out_buf << "</form>"
end

Comments

Thank you SO MUCH for posting this. It's so hard to google this without getting a TON of rails-specific stuff.