Module: Haml::Filters::Javascript

Includes:
Base
Defined in:
lib/haml/filters.rb

Overview

Surrounds the filtered text with ‘<script>` and CDATA tags. Useful for including inline Javascript.

Instance Method Summary collapse

Methods included from Base

#compile, included, #internal_compile, #lazy_require, #render

Instance Method Details

#render_with_options(text, options) ⇒ Object



192
193
194
195
196
197
198
199
200
# File 'lib/haml/filters.rb', line 192

def render_with_options(text, options)
  "<script type=\#{options[:attr_wrapper]}text/javascript\#{options[:attr_wrapper]}>\n  //<![CDATA[\n    \#{text.rstrip.gsub(\"\\n\", \"\\n    \")}\n  //]]>\n</script>\n"
end