Module: EZML::Filters::Css

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

Instance Method Summary collapse

Methods included from Base

#compile, included, #internal_compile, #render

Instance Method Details

#render_with_options(text, options) ⇒ Object



113
114
115
116
117
118
119
120
121
122
123
124
125
# File 'lib/ezml/filters.rb', line 113

def render_with_options(text, options)
  indent = options[:cdata] ? '    ' : '  ' # 4 or 2 spaces
  if options[:format] == :html5
    type = ''
  else
    type = " type=#{options[:attr_wrapper]}text/css#{options[:attr_wrapper]}"
  end

  text = text.rstrip
  text.gsub!("\n", "\n#{indent}")

  %(<style#{type}>\n#{"  /*<![CDATA[*/\n" if options[:cdata]}#{indent}#{text}\n#{"  /*]]>*/\n" if options[:cdata]}</style>)
end