matthodan / jekyll-asset-pipeline

Powerful asset pipeline for Jekyll that collects, converts and compresses JavaScript and CSS assets
http://www.matthodan.com/2012/11/22/jekyll-asset-pipeline.html
MIT License
364 stars 31 forks source link

Make config variables accessible from JekyllAssetPipeline::Converter #37

Open NV opened 11 years ago

NV commented 11 years ago

I want to compile SASS with sourcemaps for dev mode, and --output-style compressed for production mode.

I introduces a switch in _config.yml

dev: true

Can I access it from Jekyll Asset Pipeline plug-in?

module JekyllAssetPipeline
  class CompassConverter < JekyllAssetPipeline::Converter
    require 'compass'
    require 'tempfile'

    def self.filetype
      '.scss'
    end

    def initialize(asset)
      @asset = asset
      super
    end

    def convert
      output = Tempfile.new('compass_output')
      Compass.add_project_configuration({:sourcemap => true})
      Compass.configure_sass_plugin!
      Compass.compiler.compile("./source/_assets/#{@asset.filename}", output.path)
      output.read
    end
  end
end

For Jekyll::Converter it’s accessible, I believe, via @config. Can JekyllAssetPipeline::Converter make @config accessible by, for example, inheriting from Jekyll::Converter?