Class: Nokogiri::XML::Element
- Inherits:
-
Object
- Object
- Nokogiri::XML::Element
- Defined in:
- lib/html2slim/nokogiri_monkeypatches.rb
Constant Summary collapse
- BLANK_RE =
/\A[[:space:]]*\z/.freeze
Instance Method Summary collapse
Instance Method Details
#slim(lvl = 0) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/html2slim/nokogiri_monkeypatches.rb', line 41 def slim(lvl = 0) r = ' ' * lvl return r + slim_ruby_code(r) if ruby? r += name unless skip_tag_name? r += slim_id r += slim_class r += slim_attributes r end |
#to_slim(lvl = 0) ⇒ Object
53 54 55 56 57 58 59 |
# File 'lib/html2slim/nokogiri_monkeypatches.rb', line 53 def to_slim(lvl = 0) if children.count.positive? %(#{slim(lvl)}\n#{children.filter_map { |c| c.to_slim(lvl + 1) }.join("\n")}) else slim(lvl) end end |