This project is archived and is in readonly mode.

#3645 ✓resolved
Stephen Celis

Let label helpers accept blocks

Reported by Stephen Celis | January 3rd, 2010 @ 05:25 PM | in 3.0.2

Label helpers should process blocks in addition to their defaults because it's common for their content to have more complex markup than text.

This, for example,

<%= f.label :terms, "<span>Accept #{link_to 'Terms', terms_path}</span>" %>

Is much easier to read in a block

<% f.label :terms do %>
  <span>Accept <%= link_to "Terms", terms_path %></span>
<% end %>

An additional perk: in our editors, the HTML markup won't be lost in Ruby string syntax highlighting.

Patch with tests in comments.

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Referenced by

Pages