Method: HTML#htmlify

Defined in:
lib/html_compilation/classes/builders/html_builder.rb

#htmlify(string) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/html_compilation/classes/builders/html_builder.rb', line 12

def htmlify(string)
  subs = {"&" => "&amp;", '<' => "&lt;", '>' => "&gt;"}
  subs.each do |key, value|
    if string.to_s.include?(key)
      begin
        string.gsub!(key, value)
      rescue NoMethodError => e
        print e.message
      end
    end
  end
  string
end