Class: Sass::CSS
Overview
This class contains the functionality used in the css2sass
utility, namely converting CSS documents to Sass templates.
Instance Method Summary collapse
-
#initialize(template, options = {}) ⇒ CSS
constructor
Creates a new instance of Sass::CSS that will compile the given document to a Sass string when
render
is called. -
#render ⇒ Object
Processes the document and returns the result as a string containing the CSS template.
Constructor Details
#initialize(template, options = {}) ⇒ CSS
Creates a new instance of Sass::CSS that will compile the given document to a Sass string when render
is called.
114 115 116 117 118 119 120 121 |
# File 'lib/gems/haml-2.0.4/lib/sass/css.rb', line 114 def initialize(template, = {}) if template.is_a? IO template = template.read end @options = @template = StringScanner.new(template) end |
Instance Method Details
#render ⇒ Object
Processes the document and returns the result as a string containing the CSS template.
125 126 127 128 129 130 131 132 133 134 |
# File 'lib/gems/haml-2.0.4/lib/sass/css.rb', line 125 def render begin build_tree.to_sass(@options).strip + "\n" rescue Exception => err line = @template.string[0...@template.pos].split("\n").size err.backtrace.unshift "(css):#{line}" raise err end end |