1
0
Fork 0
mirror of https://github.com/haml/haml.git synced 2022-11-09 12:33:31 -05:00
haml--haml/lib/hamlit/pretty_compiler.rb
2015-10-24 20:32:24 +09:00

32 lines
616 B
Ruby

require 'hamlit/compiler'
require 'hamlit/whitespace/indented_compiler'
module Hamlit
class PrettyCompiler < Compiler
def initialize(*)
super
@indent_level = 0
@whitespace_compiler = Whitespace::IndentedCompiler.new
end
private
def compile_children(node)
@whitespace_compiler.compile_children(node, @indent_level) { |n| compile(n) }
end
def compile_comment(node)
@indent_level += 1
super
ensure
@indent_level -= 1
end
def compile_tag(node)
@indent_level += 1
super
ensure
@indent_level -= 1
end
end
end