mirror of
https://github.com/haml/haml.git
synced 2022-11-09 12:33:31 -05:00
[Sass] Add RootNode#to_sass for users to use.
This commit is contained in:
parent
650528554b
commit
f83c68825e
3 changed files with 10 additions and 8 deletions
|
@ -40,7 +40,7 @@ module Sass
|
|||
raise Sass::SyntaxError.new(msg, :line => line)
|
||||
end
|
||||
|
||||
build_tree.to_sass(0, @options).strip + "\n"
|
||||
build_tree.to_sass(@options).strip + "\n"
|
||||
rescue Sass::SyntaxError => err
|
||||
err.modify_backtrace(:filename => @options[:filename] || '(css)')
|
||||
raise err
|
||||
|
|
|
@ -190,13 +190,7 @@ module Sass
|
|||
# @param opts [{Symbol => Object}] An options hash (see {Sass::CSS#initialize})
|
||||
# @return [String] The Sass code corresponding to the node
|
||||
def to_sass(tabs = 0, opts = {})
|
||||
result = ''
|
||||
|
||||
children.each do |child|
|
||||
result << "#{' ' * tabs}#{child.to_sass(0, opts)}\n"
|
||||
end
|
||||
|
||||
result.rstrip + "\n"
|
||||
raise NotImplementedError.new("All static-node subclasses of Sass::Tree::Node must override #to_sass.")
|
||||
end
|
||||
|
||||
protected
|
||||
|
|
|
@ -44,6 +44,14 @@ module Sass
|
|||
super
|
||||
end
|
||||
|
||||
# Converts a node to Sass code that will generate it.
|
||||
#
|
||||
# @param opts [{Symbol => Object}] An options hash (see {Sass::CSS#initialize})
|
||||
# @return [String] The Sass code corresponding to the node
|
||||
def to_sass(opts = {})
|
||||
children.map {|child| child.to_sass(0, opts) + "\n"}.join.rstrip + "\n"
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
# Destructively converts this static Sass node into a static CSS node,
|
||||
|
|
Loading…
Add table
Reference in a new issue