Sha256: 2e23b4617fb82dc08c04f3fad94abc2e845a90ef15312f88e4033d7451d070c8
Contents?: true
Size: 619 Bytes
Versions: 1
Compression:
Stored size: 619 Bytes
Contents
#!/usr/bin/env ruby # frozen_string_literal: true require 'treetop' require_relative 'node' # Base rule for lists of images, metas, styles, and scripts class PairList < Node 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 end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
emerald-lang-1.0.0 | lib/emerald/nodes/pair_list.rb |