Module: Haml::Filters::Javascript
- Includes:
- Base
- Defined in:
- /tmp/buildd/ruby-haml-3.1.6/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)
200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 |
# File '/tmp/buildd/ruby-haml-3.1.6/lib/haml/filters.rb', line 200
def render_with_options(text, options)
if options[:format] == :html5
type = ''
else
type = " type=#{options[:attr_wrapper]}text/javascript#{options[:attr_wrapper]}"
end
<<END
<script#{type}>
//<![CDATA[
#{text.rstrip.gsub("\n", "\n ")}
//]]>
</script>
END
end
|