Sha256: d360604acf5ea1da65f731ee5b538135546b84b35d3606ddc1ec3a98f701241a

Contents?: true

Size: 834 Bytes

Versions: 7

Compression:

Stored size: 834 Bytes

Contents

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

require_relative "context"
require_relative "tag"

# --
module Jekyll
  module Assets
    module Context
      # --
      # Allows you to get an asset by it's path.
      # @note this SASS helper fully supports proxy arguments.
      # @param [Hash] opts this is unused but necessary.
      # @param [String] path the path.
      # @return [String] the path.
      # --
      def asset_path(path, _ = {})
        ctx1 = Liquid::ParseContext.new
        ctx2 = Liquid::Context.new({}, {}, site: environment.jekyll)
        Jekyll::Assets::Tag.new("img", "#{path} @path", ctx1)
          .render(ctx2)
      end
    end
  end
end

# --
Jekyll::Assets::Hook.register(:env, :after_init) do
  context_class.send(:include, Jekyll::Assets::Context)
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
jekyll-assets-3.0.12 lib/jekyll/assets/context.rb
jekyll-assets-3.0.11 lib/jekyll/assets/context.rb
jekyll-assets-3.0.10 lib/jekyll/assets/context.rb
jekyll-assets-3.0.9 lib/jekyll/assets/context.rb
jekyll-assets-3.0.8 lib/jekyll/assets/context.rb
jekyll-assets-3.0.7 lib/jekyll/assets/context.rb
jekyll-assets-3.0.6 lib/jekyll/assets/context.rb