instance method
tag
Ruby on Rails 2.2.3
Since v2.2.3Signature
tag(name, options = nil, open = false, escape = true)
Returns an empty HTML tag of type name which by default is XHTML compliant. Set open to true to create an open tag compatible with HTML 4.0 and below. Add HTML attributes by passing an attributes hash to options. Set escape to false to disable attribute value escaping.
Options
The options hash is used with attributes with no value like (disabled and readonly), which you can give a value of true in the options hash. You can use symbols or strings for the attribute names.
Examples
tag("br") # => <br /> tag("br", nil, true) # => <br> tag("input", { :type => 'text', :disabled => true }) # => <input type="text" disabled="disabled" /> tag("img", { :src => "open & shut.png" }) # => <img src="open & shut.png" /> tag("img", { :src => "open & shut.png" }, false, false) # => <img src="open & shut.png" />
Parameters
-
namereq -
optionsopt = nil -
openopt = false -
escapeopt = true
Source
# File actionpack/lib/action_view/helpers/tag_helper.rb, line 41
def tag(name, options = nil, open = false, escape = true)
"<#{name}#{tag_options(options, escape) if options}#{open ? ">" : " />"}"
end
Defined in actionpack/lib/action_view/helpers/tag_helper.rb line 41
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActionView::Helpers::TagHelper