public Method

TagHelper.tag(name, options = nil, open = false, escape = true)

Contents:

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 &amp; shut.png" />

tag("img", { :src => "open &amp; shut.png" }, false, false)
# => <img src="open &amp; shut.png" />

Source Code

# File action_view/helpers/tag_helper.rb, line 39
def tag(name, options = nil, open = false, escape = true)
  "<#{name}#{tag_options(options, escape) if options}" + (open ? ">" : " />")
end
Comments

Have your say
Please use Textile formatting (click here for a cheat sheet). Use <code/> and <pre/> for code samples.
Click here to login with OpenID to to post comments.