# Module: Haml::Filters::Css

Includes:
  Base

Defined in:
  lib/haml/filters.rb

## Overview

Surrounds the filtered text with `<style>` and CDATA tags. Useful for including inline CSS.

## Instance Method Summary collapse

- #render_with_options(text, options)

### Methods included from Base

#compile, included, #internal_compile, #render

## Instance Method Details

### #render_with_options(text, options)

See Also:

- Base#render_with_options

    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245

    # File 'lib/haml/filters.rb', line 233

    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