Sha256: 4b4cadd1cfab01af81fb4e6a64317866e5cc3577cb95ea2d4023e597521fd5bf
Contents?: true
Size: 784 Bytes
Versions: 34
Compression:
Stored size: 784 Bytes
Contents
module IsoDoc module ClassUtils def date_range(date) from = date.at(ns("./from")) to = date.at(ns("./to")) on = date.at(ns("./on")) return on.text if on ret = "#{from.text}–" ret += to.text if to ret end def ns(xpath) xpath.gsub(%r{/([a-zA-z])}, "/xmlns:\\1"). gsub(%r{::([a-zA-z])}, "::xmlns:\\1"). gsub(%r{\[([a-zA-z][a-z0-9A-Z@/]* ?=)}, "[xmlns:\\1"). gsub(%r{\[([a-zA-z][a-z0-9A-Z@/]*\])}, "[xmlns:\\1") end def liquid(doc) # unescape HTML escapes in doc doc = doc.split(%r<(\{%|\}%)>).each_slice(4).map do |a| a[2].gsub!("<", "<").gsub!(">", ">") if a.size > 2 a.join("") end.join("") Liquid::Template.parse(doc) end end end
Version data entries
34 entries across 34 versions & 1 rubygems