The tags module is accessible via the webhelpers.rails module.
Use these methods to generate XHTML comliant tags programmatically.
Returns an XHTML compliant tag of type name.
All additional keyword args become attribute/value's for the tag. To pass in Python reserved words, append _ to the name of the key. For attributes with no value (such as disabled and readonly), a value of True is permitted.
Examples:
>>> tag("br")
'<br />'
>>> tag("br", True)
'<br>'
>>> tag("input", type="text")
'<input type="text" />'
>>> tag("input", type='text', disabled=True)
'<input disabled="disabled" type="text" />'
Create a tag with content
Takes the same keyword args as tag
Examples:
>>> content_tag("p", "Hello world!")
'<p>Hello world!</p>'
>>> content_tag("div", content_tag("p", "Hello world!"), class_="strong")
'<div class="strong"><p>Hello world!</p></div>'
Returns a CDATA section with the given content.
CDATA sections are used to escape blocks of text containing characters which would otherwise be recognized as markup. CDATA sections begin with the string <![CDATA[ and end with (and may not contain) the string ]]>.
Escapes a given string without affecting existing escaped entities.
>>> escape_once("1 < 2 & 3")
'1 < 2 & 3'
See the source for more information.