TagHelper
TagHelper
may be of use when you want to create explicit XHTML
markup using ERb templates, or want to create view logic that lets the
data determine which markup is used. On the one hand, these methods are
somewhat obscure; on the other, they may be exactly what you need if
clean XHTML is your goal:
cdata_section
As its name suggests, the
cdata_section
method lets you create CDATA sections wrapping the content specified in the argument. (CDATA sections let you mark sections of an XML document as not containing any markup, so you can use<
,>
, and&
to your heartâs content.)content_tag
The
content_tag
method is a generic tag building method. You define the name of the tag, the attributes, and the content of the tag through the arguments.escape_once
The
escape_once
method is extremely convenient when you have content that needs<
,>
, and&
escapedâbut you might already have done some of the escaping. This method is smart enough to escape markup text that needs escaping, while leaving the ampersands that are part of prior escaping alone.tag
The
tag
method creates an empty tag (like<br />
).
Get Learning Rails now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.