Permalink
Browse files

Refactor Index monkey-patching

  • Loading branch information...
ixti committed Feb 12, 2013
1 parent 060febb commit 01473c81319fff9e528772d87836a5c4223d618b
Showing with 23 additions and 15 deletions.
  1. +2 −15 lib/jekyll/assets_plugin/environment.rb
  2. +21 −0 lib/jekyll/assets_plugin/environment/index_patch.rb
@@ -19,6 +19,7 @@ def initialize path
autoload :ContextPatch, "jekyll/assets_plugin/environment/context_patch"
+ autoload :IndexPatch, "jekyll/assets_plugin/environment/index_patch"
attr_reader :site
@@ -51,21 +52,7 @@ def find_asset path, *args
def index
- super.tap do |index|
- index.instance_eval do
- def find_asset path, options = {}
- site = @environment.site
- asset = super
- bundle = options[:bundle]
-
- if asset and bundle and not site.static_files.include? asset
- site.static_files << AssetFile.new(site, asset)
- end
-
- asset
- end
- end
- end
+ super.tap { |index| index.singleton_class.send :include, IndexPatch }
end
end
@@ -0,0 +1,21 @@
+module Jekyll
+ module AssetsPlugin
+ class Environment
+ module IndexPatch
+
+ def find_asset path, options = {}
+ site = @environment.site
+ asset = super
+ bundle = options[:bundle]
+
+ if asset and bundle and not site.static_files.include? asset
+ site.static_files << AssetFile.new(site, asset)
+ end
+
+ asset
+ end
+
+ end
+ end
+ end
+end

0 comments on commit 01473c8

Please sign in to comment.