Class: Sass::Tree::WarnNode

Inherits:
Node
  • Object
show all
Defined in:
lib/sass/tree/warn_node.rb

Overview

A dynamic node representing a Sass @warn statement.

See Also:

Instance Attribute Summary

Attributes inherited from Node

#children, #filename, #has_children, #line, #options

Instance Method Summary collapse

Methods inherited from Node

#<<, #==, #_cssize, #_to_s, #balance, #check_child!, #children_to_src, #cssize, #cssize!, #dasherize, #do_extend, #each, #invalid_child?, #invisible?, #perform, #perform!, #perform_children, #render, #run_interp, #semi, #style, #to_s, #to_sass, #to_scss

Constructor Details

#initialize(expr) ⇒ WarnNode

Returns a new instance of WarnNode.

Parameters:



8
9
10
11
# File 'lib/sass/tree/warn_node.rb', line 8

def initialize(expr)
  @expr = expr
  super()
end

Instance Method Details

#_perform(environment) (protected)

Prints the expression to STDERR with a stylesheet trace.

Parameters:

  • environment (Sass::Environment)

    The lexical environment containing variable and mixin values



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/sass/tree/warn_node.rb', line 24

def _perform(environment)
  environment.push_frame(:filename => filename, :line => line)
  res = @expr.perform(environment)
  res = res.value if res.is_a?(Sass::Script::String)
  msg = "WARNING: #{res}\n"
  environment.stack.reverse.each_with_index do |entry, i|
    msg << "        #{i == 0 ? "on" : "from"} line #{entry[:line]}" <<
      " of #{entry[:filename] || "an unknown file"}"
    msg << ", in `#{entry[:mixin]}'" if entry[:mixin]
    msg << "\n"
  end
  Haml::Util.haml_warn msg
  []
ensure
  environment.pop_frame
end

#to_src(tabs, opts, fmt) (protected)

See Also:



16
17
18
# File 'lib/sass/tree/warn_node.rb', line 16

def to_src(tabs, opts, fmt)
  "#{'  ' * tabs}@warn #{@expr.to_sass(opts)}#{semi fmt}\n"
end