Sha256: 4a8073b8bab6053abcc796fd03e8205956d2ec8808ac0fcef4735d63dfaff319

Contents?: true

Size: 770 Bytes

Versions: 4

Compression:

Stored size: 770 Bytes

Contents

# (c) Copyright 2020 Ribose Inc.
#

module Jekyll
  module Geolexica
    module Filters
      # Renders authoritative source hash as HTML.
      #
      # @param input [Hash] authoritative source hash.
      # @return [String]
      #
      # TODO Maybe support string inputs.
      def display_authoritative_source(input)
        ref, clause, link = input.values_at("ref", "clause", "link") rescue nil

        return "" if ref.nil? && link.nil?

        ref_caption = escape_once(ref || link)
        ref_part = link ? %[<a href="#{link}">#{ref_caption}</a>] : ref_caption

        clause_part = clause && escape_once(clause)

        [ref_part, clause_part].compact.join(", ")
      end
    end
  end
end

Liquid::Template.register_filter(Jekyll::Geolexica::Filters)

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
jekyll-geolexica-1.7.0 lib/jekyll/geolexica/filters.rb
jekyll-geolexica-1.6.0 lib/jekyll/geolexica/filters.rb
jekyll-geolexica-1.5.4 lib/jekyll/geolexica/filters.rb
jekyll-geolexica-1.5.3 lib/jekyll/geolexica/filters.rb