Why isn't `:escape => false` supported by all ActionView tag generators?

108 views Asked by At

I need to generate a hidden input element with ActionView::Helpers::FormTagHelper#hidden_field_tag, but I don't want the input value to be escaped.

What I would like to do is this:

<%= hidden_field_tag('hidden_input', sanitize('actual_input_value'), :escape => false) %>

But this just renders an HTML input with escape="false" as an attribute.

I can get around this by avoiding the FormTagHelper#hidden_field_tag method and using TagHelper#tag directly:

<%= tag('input', { :name => 'hidden_input', :value => sanitize('actual_input_value'), :type => 'hidden', }, false, false).html_safe %>

But this is more verbose and less readable, particularly given that I have several usages of #hidden_field_tag very close to this tag generation.

Is my desired functionality absent by design, or is this a feature that could be added into ActionPack? It is present for at least one other helper method (see ActionView::Helpers::FormTagHelper#text_area_tag)

0

There are 0 answers