Class: Sass::Tree::Visitors::ToCss

Inherits:
Base
  • Object
show all
Defined in:
lib/sassmagic/reset.rb

Overview

重写属性解析to_css.rb A visitor for converting a Sass tree into CSS.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(build_source_mapping = false) ⇒ ToCss

Returns a new instance of ToCss.

Parameters:

  • build_source_mapping (Boolean) (defaults to: false)

    Whether to build a Source::Map while creating the CSS output. The mapping will be available from #source_mapping after the visitor has completed.



205
206
207
208
209
210
211
# File 'lib/sassmagic/reset.rb', line 205

def initialize(build_source_mapping = false)
  @tabs = 0
  @line = 1
  @offset = 1
  @result = ""
  @source_mapping = Sass::Source::Map.new if build_source_mapping
end

Instance Attribute Details

#source_mappingObject (readonly)

The source mapping for the generated CSS file. This is only set if ‘build_source_mapping` is passed to the constructor and Engine#render has been run.



200
201
202
# File 'lib/sassmagic/reset.rb', line 200

def source_mapping
  @source_mapping
end

Instance Method Details

#visit(node) ⇒ String

Runs the visitor on ‘node`.

Parameters:

  • node (Sass::Tree::Node)

    The root node of the tree to convert to CSS>

Returns:

  • (String)

    The CSS output.



217
218
219
220
221
222
# File 'lib/sassmagic/reset.rb', line 217

def visit(node)
  super
rescue Sass::SyntaxError => e
  e.modify_backtrace(:filename => node.filename, :line => node.line)
  raise e
end