Class: Haml::Engine

Inherits:
Object show all
Defined in:
lib/xss_shield/haml_hacks.rb

Instance Method Summary collapse

Instance Method Details

#build_attributes(attributes = {}) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/xss_shield/haml_hacks.rb', line 18

def build_attributes(attributes = {})
  # We ignore @options[:attr_wrapper] because ERB::Util.h does not espace ' to '
  # making ' as attribute quote not workable
  result = attributes.map do |a,v|
    v = v.to_s_xss_protected
    unless v.blank?
      " #{a}=\"#{v}\""
    end
  end
  result.sort.join
end

#push_script(text, flattened) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/xss_shield/haml_hacks.rb', line 5

def push_script(text, flattened)
  unless options[:suppress_eval]
    push_silent("haml_temp = #{text}", true)
    push_silent("haml_temp = haml_temp.to_s_xss_protected", true)
    out = "haml_temp = _hamlout.push_script(haml_temp, #{@output_tabs}, #{flattened})\n"
    if @block_opened
      push_and_tabulate([:loud, out])
    else
      @precompiled << out
    end
  end
end