Module: Tenjin::HtmlHelper
- Included in:
- Context
- Defined in:
- lib/tenjin.rb
Overview
helper module for Context class. depends on SafeHelper.
Constant Summary collapse
- XML_ESCAPE_TABLE =
{ '&'=>'&', '<'=>'<', '>'=>'>', '"'=>'"', "'"=>''' }
Class Method Summary collapse
-
.escape_html(s) ⇒ Object
(also: escape, h)
escapes ‘&’, ‘<’, ‘>’, ‘“’, and ‘'’.
-
.escape_xml(s) ⇒ Object
escapes ‘&’, ‘<’, ‘>’, and ‘“’.
Instance Method Summary collapse
-
#escape_html(s) ⇒ Object
escapes ‘&’, ‘<’, ‘>’, ‘“’, and ‘'’.
-
#escape_xml(s) ⇒ Object
escapes ‘&’, ‘<’, ‘>’, and ‘“’.
Class Method Details
.escape_html(s) ⇒ Object Also known as: escape, h
escapes ‘&’, ‘<’, ‘>’, ‘“’, and ‘'’
68 69 70 71 |
# File 'lib/tenjin.rb', line 68 def escape_html(s) #s.gsub(/[&<>"']/) { XML_ESCAPE_TABLE[$&] } s.gsub(/[&<>"']/) {|s| XML_ESCAPE_TABLE[s] } end |
.escape_xml(s) ⇒ Object
escapes ‘&’, ‘<’, ‘>’, and ‘“’
62 63 64 65 |
# File 'lib/tenjin.rb', line 62 def escape_xml(s) #s.gsub(/[&<>"]/) { XML_ESCAPE_TABLE[$&] } s.gsub(/[&<>"]/) {|s| XML_ESCAPE_TABLE[s] } end |
Instance Method Details
#escape_html(s) ⇒ Object
escapes ‘&’, ‘<’, ‘>’, ‘“’, and ‘'’
68 69 70 71 |
# File 'lib/tenjin.rb', line 68 def escape_html(s) #s.gsub(/[&<>"']/) { XML_ESCAPE_TABLE[$&] } s.gsub(/[&<>"']/) {|s| XML_ESCAPE_TABLE[s] } end |
#escape_xml(s) ⇒ Object
escapes ‘&’, ‘<’, ‘>’, and ‘“’
62 63 64 65 |
# File 'lib/tenjin.rb', line 62 def escape_xml(s) #s.gsub(/[&<>"]/) { XML_ESCAPE_TABLE[$&] } s.gsub(/[&<>"]/) {|s| XML_ESCAPE_TABLE[s] } end |