Method: ActionView::Helpers::TagHelper#cdata_section

Defined in:
lib/action_view/helpers/tag_helper.rb

#cdata_section(content) ⇒ Object

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 and end with (and may not contain) the string ]]>.

Examples

cdata_section("")

=> ]]>

cdata_section(File.read("hello_world.txt"))
# => <![CDATA[<hello from a text file]]>


94
95
96
# File 'lib/action_view/helpers/tag_helper.rb', line 94

def cdata_section(content)
  "<![CDATA[#{content}]]>".html_safe
end