lib/fast_haml/ast.rb in fast_haml-0.1.3 vs lib/fast_haml/ast.rb in fast_haml-0.1.4

- old
+ new

@@ -1,23 +1,7 @@ module FastHaml module Ast - module LineCounter - def initialize(*) - super - @trailing_empty_lines = 0 - end - - def trailing_empty_lines - @trailing_empty_lines - end - - def increment_trailing_empty_lines - @trailing_empty_lines += 1 - nil - end - end - module HasChildren def initialize(*) super self.children ||= [] end @@ -26,16 +10,25 @@ self.children << ast end end class Root < Struct.new(:children) - include LineCounter include HasChildren + attr_reader :leading_empty_lines + + def initialize(*) + super + @leading_empty_lines = 0 + end + + def increment_leading_empty_lines + @leading_empty_lines +=1 + nil + end end class Doctype < Struct.new(:doctype) - include LineCounter end class Element < Struct.new( :children, :tag_name, @@ -45,11 +38,10 @@ :oneline_child, :self_closing, :nuke_inner_whitespace, :nuke_outer_whitespace, ) - include LineCounter include HasChildren def initialize(*) super self.static_class ||= '' @@ -66,11 +58,10 @@ :script, :escape_html, :preserve, :mid_block_keyword, ) - include LineCounter include HasChildren def initialize(*) super if self.escape_html.nil? @@ -84,11 +75,10 @@ end end end class SilentScript < Struct.new(:children, :script, :mid_block_keyword) - include LineCounter include HasChildren def initialize(*) super if self.mid_block_keyword.nil? @@ -96,41 +86,38 @@ end end end class HtmlComment < Struct.new(:children, :comment, :conditional) - include LineCounter include HasChildren def initialize(*) super self.comment ||= '' self.conditional ||= '' end end class HamlComment < Struct.new(:children) - include LineCounter include HasChildren end class Text < Struct.new(:text, :escape_html) - include LineCounter - def initialize(*) super if self.escape_html.nil? self.escape_html = true end end end class Filter < Struct.new(:name, :texts) - include LineCounter - def initialize(*) super self.texts ||= [] end + end + + class Empty end end end