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

Inherits:
Base
  • Object
show all
Defined in:
.ruby-sass/lib/sass/tree/visitors/to_css.rb

Overview

A visitor for converting a Sass tree into CSS.

Constant Summary

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Methods inherited from Base

visit

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.



11
12
13
14
15
16
17
18
19
# File '.ruby-sass/lib/sass/tree/visitors/to_css.rb', line 11

def initialize(build_source_mapping = false)
  @tabs = 0
  @line = 1
  @offset = 1
  @result = String.new("")
  @source_mapping = build_source_mapping ? Sass::Source::Map.new : nil
  @lstrip = nil
  @in_directive = false
end

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.



11
12
13
14
15
16
17
18
19
# File '.ruby-sass/lib/sass/tree/visitors/to_css.rb', line 11

def initialize(build_source_mapping = false)
  @tabs = 0
  @line = 1
  @offset = 1
  @result = String.new("")
  @source_mapping = build_source_mapping ? Sass::Source::Map.new : nil
  @lstrip = nil
  @in_directive = false
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.



6
7
8
# File '.ruby-sass/lib/sass/tree/visitors/to_css.rb', line 6

def source_mapping
  @source_mapping
end

Instance Method Details

#visit(node) ⇒ String

Runs the visitor on `node`.

Parameters:

Returns:

  • (String)

    The CSS output.



25
26
27
28
29
30
# File '.ruby-sass/lib/sass/tree/visitors/to_css.rb', line 25

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