Module: Haml::Filters::Javascript

Includes:
Base
Defined in:
lib/jsdefer-haml.rb

Instance Method Summary collapse

Instance Method Details

#render_with_options(text, options) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/jsdefer-haml.rb', line 9

def render_with_options(text, options)
  if options[:format] == :html5
    type = ''
  else
    type = " type=#{options[:attr_wrapper]}text/javascript#{options[:attr_wrapper]}"
  end

  JsDefer.instance.push_script "<script#{type}>
  //<![CDATA[
    #{text.rstrip.gsub("\n", "\n    ")}
  //]]>
</script>"
  nil
end