Sha256: c3a3710fb7276ed821d8224fa9f9818a5e15ee21b50a832802c3f6d844b351ce

Contents?: true

Size: 1.2 KB

Versions: 3

Compression:

Stored size: 1.2 KB

Contents

# ----------------------------------------------------------------------------
# Frozen-string-literal: true
# Copyright: 2012 - 2016 - MIT License
# Encoding: utf-8
# ----------------------------------------------------------------------------

module Jekyll
  module Assets
    module Liquid
      module Filters
        ACCEPTABLE_FILTERS = [:css, :img, :asset_path, :stylesheet,
          :javascript, :style, :image, :js]

        # --
        # The base filters.
        # --
        ACCEPTABLE_FILTERS.each do |val|
          define_method val do |path, args = ""|
            Tag.send(:new, val, "#{path} #{args}", ParseContext.new).render(
              @context
            )
          end
        end

        # --
        # Include multiple assets.
        # @return [Strings]
        # --
        def jekyll_asset_multi(assets)
          return Shellwords.shellsplit(assets).map { |s| s.split(":", 2) }.map do |tag, arguments|
            Tag.send(:new, tag, arguments, ParseContext.new).render(
              @context
            )
          end \

          .join(
            "\n"
          )
        end
      end

      #

      ::Liquid::Template.register_filter(
        Filters
      )
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
jekyll-assets-2.4.0 lib/jekyll/assets/liquid/filters.rb
jekyll-assets-2.3.2 lib/jekyll/assets/liquid/filters.rb
jekyll-assets-2.3.0 lib/jekyll/assets/liquid/filters.rb