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_sectionAs its name suggests, the
cdata_sectionmethod 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_tagThe
content_tagmethod 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_onceThe
escape_oncemethod 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.tagThe
tagmethod creates an empty tag (like<br />).
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access