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

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.


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.


  # => <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" />
Show source
Register or log in to add new notes.
April 19, 2012 - (v3.1.0 - v3.2.1)
0 thanks

Missed close tag

At the page http://apidock.com/rails/ActionView/Helpers/TagHelper/tag

<tt>.data()</tt> should be instead of <tt>.data()<tt>