Sha256: 143d053b543ca2304c384ee9fc086dfa83476ab5de221d8bdeadb2f251ab9fca

Contents?: true

Size: 1.09 KB

Versions: 1

Compression:

Stored size: 1.09 KB

Contents

# 3rd-party
require "sprockets"


# internal
require "jekyll/assets_plugin/asset_file"
require "jekyll/assets_plugin/liquid_processor"


module Jekyll
  module AssetsPlugin
    class Environment < Sprockets::Environment

      class AssetNotFound < StandardError
        def initialize path
          super "Couldn't find file '#{path}'"
        end
      end


      attr_reader :site


      def initialize site
        super site.source

        @site = site

        # append asset paths
        @site.assets_config.sources.each { |p| append_path p }

        self.js_compressor   = @site.assets_config.js_compressor
        self.css_compressor  = @site.assets_config.css_compressor

        register_preprocessor "text/css",               LiquidProcessor
        register_preprocessor "application/javascript", LiquidProcessor

        # bind jekyll and Sprockets context together
        context_class.instance_variable_set :@site, @site

        context_class.send :include, Patches::ContextPatch
      end


      def find_asset path, *args
        super or raise AssetNotFound, path
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jekyll-assets-0.3.6 lib/jekyll/assets_plugin/environment.rb