Tuesday, April 15, 2008

rails helper block

Write for memo.
To set a helper in the form

<% helper_name do %>
<% end %>

The definition is

def helper_name(&block)
    content = capture(&block)
    concat("what we want write before block".block.binding)
    concat("what we want write after block",block.binding)

By the way, partial is the way do the same thing once. if the outer html is used frequently, the way to define a helper as above will be better.

No comments: