2008-12-24 19:33:47 -08:00
|
|
|
module Sass
|
|
|
|
module Tree
|
2009-04-25 02:08:37 -07:00
|
|
|
# A dynamic node representing a Sass `@debug` statement.
|
|
|
|
#
|
|
|
|
# @see Sass::Tree
|
2008-12-24 19:33:47 -08:00
|
|
|
class DebugNode < Node
|
2009-04-25 02:08:37 -07:00
|
|
|
# @param expr [Script::Node] The expression to print
|
2009-04-21 19:25:18 -07:00
|
|
|
def initialize(expr)
|
2008-12-24 19:33:47 -08:00
|
|
|
@expr = expr
|
2009-04-21 19:25:18 -07:00
|
|
|
super()
|
2008-12-24 19:33:47 -08:00
|
|
|
end
|
|
|
|
|
2010-01-28 17:22:35 -08:00
|
|
|
protected
|
2010-01-28 14:46:10 -08:00
|
|
|
|
2010-04-20 02:55:28 -07:00
|
|
|
# @see Node#to_src
|
2010-01-28 17:22:35 -08:00
|
|
|
def to_src(tabs, opts, fmt)
|
2010-04-10 11:23:28 -07:00
|
|
|
"#{' ' * tabs}@debug #{@expr.to_sass(opts)}#{semi fmt}\n"
|
2010-01-26 22:27:18 -08:00
|
|
|
end
|
|
|
|
|
2009-04-25 02:08:37 -07:00
|
|
|
# Prints the expression to STDERR.
|
|
|
|
#
|
|
|
|
# @param environment [Sass::Environment] The lexical environment containing
|
|
|
|
# variable and mixin values
|
2008-12-24 19:33:47 -08:00
|
|
|
def _perform(environment)
|
|
|
|
res = @expr.perform(environment)
|
2010-03-25 17:19:50 -07:00
|
|
|
res = res.value if res.is_a?(Sass::Script::String)
|
2008-12-24 19:33:47 -08:00
|
|
|
if filename
|
2009-12-31 16:40:27 -08:00
|
|
|
$stderr.puts "#{filename}:#{line} DEBUG: #{res}"
|
2008-12-24 19:33:47 -08:00
|
|
|
else
|
2009-12-31 16:40:27 -08:00
|
|
|
$stderr.puts "Line #{line} DEBUG: #{res}"
|
2008-12-24 19:33:47 -08:00
|
|
|
end
|
|
|
|
[]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|