Class: PairList

Inherits:
Node
  • Object
show all
Defined in:
lib/emerald/nodes/pair_list.rb

Overview

Base rule for lists of images, metas, styles, and scripts

Instance Method Summary collapse

Instance Method Details

#to_html(context) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/emerald/nodes/pair_list.rb', line 9

def to_html(context)
  list_items.elements.map do |e|
    attrs = e.pairs.elements.map do |j|
      "#{j.attr.text_value}=\"#{j.literal.to_html(context)}\""
    end.join(' ')

    case keyword.text_value
    when 'images'  then "<img #{attrs}/>"
    when 'metas'   then "<meta #{attrs}>"
    when 'styles'  then "<link #{attrs}/>"
    when 'scripts' then "<script #{attrs}></script>"
    end
  end.join("\n")
end