lib/fast_haml/ast.rb in fast_haml-0.1.1 vs lib/fast_haml/ast.rb in fast_haml-0.1.2

- old
+ new

@@ -1,8 +1,21 @@ module FastHaml module Ast - module Construct + 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 @@ -13,14 +26,16 @@ self.children << ast end end class Root < Struct.new(:children) + include LineCounter include HasChildren end class Doctype < Struct.new(:doctype) + include LineCounter end class Element < Struct.new( :children, :tag_name, @@ -30,10 +45,11 @@ :oneline_child, :self_closing, :nuke_inner_whitespace, :nuke_outer_whitespace, ) + include LineCounter include HasChildren def initialize(*) super self.static_class ||= '' @@ -50,10 +66,11 @@ :script, :escape_html, :preserve, :mid_block_keyword, ) + include LineCounter include HasChildren def initialize(*) super if self.escape_html.nil? @@ -67,10 +84,11 @@ 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? @@ -78,32 +96,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