Module: Presenting::Sanitize

Extended by:
ERB::Util
Defined in:
lib/presenting/sanitize.rb

Class Method Summary collapse

Class Method Details

.h(val) ⇒ Object

escape but preserve Arrays and Hashes



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/presenting/sanitize.rb', line 6

def h(val)
  case val
  when Array
    val.map{|i| h(i)}
    
  when Hash
    val.clone.each{|k, v| val[h(k)] = h(v)}
    
  else
    html_escape(val)
  end
end