Class: Hpricot::Elem

Inherits:
Object
  • Object
show all
Defined in:
lib/html2slim/hpricot_monkeypatches.rb

Constant Summary collapse

BLANK_RE =
/\A[[:space:]]*\z/

Instance Method Summary collapse

Instance Method Details

#slim(lvl = 0) ⇒ Object



49
50
51
52
53
54
55
56
57
58
59
# File 'lib/html2slim/hpricot_monkeypatches.rb', line 49

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



61
62
63
64
65
66
67
# File 'lib/html2slim/hpricot_monkeypatches.rb', line 61

def to_slim(lvl=0)
  if respond_to?(:children) and children
    return %(#{slim(lvl)}\n#{children.map{|c| c.to_slim(lvl+1) }.select{|e| !e.nil? }.join("\n")})
  else
    slim(lvl)
  end
end