Escaping [ ]


#1

I need a label tag that is like this…

Password

how do i escape it in the label_tag?

<%= label_tag ‘user_session[password]’, ‘Password’, :class =>
‘menulogin’ %>

I keep getting _ for [ and ]


#2

On Wed, May 27, 2009 at 12:47 PM, spokra removed_email_address@domain.invalid wrote:

I keep getting _ for [ and ]

Internally, label_tag is calling content_tag, but it is sanitizing the
name you pass in. Intuitively, your snippet should work. I don’t know
why the label_tag method is mucking it up.

But, you can bypass label_tag() and go straight to content_tag() and
get what you expect with:

<%= content_tag(:label, “Password”, {:for => ‘user_session[password]’,
:class => “menulogin”}) %>


Steven H. removed_email_address@domain.invalid