Class: Nokogiri::XML::Comment

Inherits:
Object
  • Object
show all
Defined in:
lib/html2haml/html.rb

Overview

See Also:

Instance Method Summary collapse

Instance Method Details

#to_haml(tabs, options) ⇒ Object

See Also:

  • Html2haml::HTML::Node#to_haml


273
274
275
276
277
278
279
280
281
282
283
284
285
# File 'lib/html2haml/html.rb', line 273

def to_haml(tabs, options)
  content = self.content
  if content =~ /\A(\[[^\]]+\])>(.*)<!\[endif\]\z/m
    condition = $1
    content = $2
  end

  if content.include?("\n")
    "#{tabulate(tabs)}/#{condition}\n#{parse_text(content, tabs + 1)}"
  else
    "#{tabulate(tabs)}/#{condition} #{content.strip}\n"
  end
end