This class contains the functionality used in the css2sass utility, namely converting CSS documents to Sass templates.
Public class methods
new
(template, options = {})
Creates a new instance of Sass::CSS that will compile the given document to a Sass string when render is called.
[show source]
# File lib/sass/css.rb, line 108 108: def initialize(template, options = {}) 109: if template.is_a? IO 110: template = template.read 111: end 112: 113: @options = options 114: @template = StringScanner.new(template) 115: end
Public instance methods
render
()
Processes the document and returns the result as a string containing the CSS template.
[show source]
# File lib/sass/css.rb, line 119 119: def render 120: begin 121: build_tree.to_sass(@options).lstrip 122: rescue Exception => err 123: line = @template.string[0...@template.pos].split("\n").size 124: 125: err.backtrace.unshift "(css):#{line}" 126: raise err 127: end 128: end