Sha256: e8cbfcb054a4f9fcf5fd5cdecf7aaa302fb2fbec98258973d7f9f009e071a695

Contents?: true

Size: 826 Bytes

Versions: 2

Compression:

Stored size: 826 Bytes

Contents

# frozen_string_literal: true

module Archangel
  module Liquid
    ##
    # Archangel custom Liquid filters
    #
    module Filters
      ##
      # Link custom filters for Liquid
      #
      module LinkToFilter
        ##
        # link_to a string
        #
        # Example
        #   {{ "Some text" | link_to: "https://example.com" }}
        #     # => "<a href="https://example.com">Some text</a>"
        #
        # @param link_text [String] string to link
        # @return [String] the link
        #
        # :reek:UtilityFunction
        def link_to(link_text, *args)
          link = args.first

          return link_text if link.blank?

          "<a href=\"#{link}\">#{link_text}</a>"
        end
      end
    end
  end
end

::Liquid::Template.register_filter(Archangel::Liquid::Filters::LinkToFilter)

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
archangel-0.4.0 lib/archangel/liquid/filters/link_to_filter.rb
archangel-0.3.0 lib/archangel/liquid/filters/link_to_filter.rb