class Mok::ItemList

Public Instance Methods

apply() click to toggle source
# File lib/mok2html_element.rb, line 72
def apply
  return "" if @contents.empty?
  type = :dummy
  str = "<ul>\n"
  @contents.each do |item|
    type_pre = type
    case item
    when :INDENT
      type = :indent
      str += "\n<ul>\n"
    when :DEDENT
      type = :dedent
      str += "</li>\n" if type_pre == :item
      str += "</ul>\n</li>\n"
    else
      type = :item
      str += "</li>\n" if type_pre == :item
      str += "<li>#{item.apply}"
    end
  end
  str += "\n</li>"  if type == :item
  str += "\n</ul>\n"
  str
end