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 =
{ '&'=>'&amp;', '<'=>'&lt;', '>'=>'&gt;', '"'=>'&quot;', "'"=>'&#039;' }

Class Method Summary collapse

Instance Method Summary collapse

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