class HtmlToHaml::Html::IndentationTracker
Public Class Methods
new(indentation_amount:)
click to toggle source
# File lib/html_to_haml/tools/html/indentation_tracker.rb, line 5 def initialize(indentation_amount:) @indentation_level = 0 @inside_self_closing_tag = false @indentation_amount = indentation_amount end
Public Instance Methods
close_html_tag()
click to toggle source
# File lib/html_to_haml/tools/html/indentation_tracker.rb, line 20 def close_html_tag @indentation_level -= @indentation_amount if @indentation_level < 0 raise ParseError, 'The html is malformed and is attempting to close an html tag that was never started' end end
indentation()
click to toggle source
# File lib/html_to_haml/tools/html/indentation_tracker.rb, line 27 def indentation " " * @indentation_level end
start_html_tag()
click to toggle source
# File lib/html_to_haml/tools/html/indentation_tracker.rb, line 11 def start_html_tag @indentation_level += @indentation_amount unless @inside_self_closing_tag @inside_self_closing_tag = false end
start_self_closing_tag()
click to toggle source
# File lib/html_to_haml/tools/html/indentation_tracker.rb, line 16 def start_self_closing_tag @inside_self_closing_tag = true end