从Rake任务访问插件

时间:2023-01-25 08:08:47

How would I go about accessing the Bundle-Fu plugin from this rake task?

我如何从这个rake任务访问Bundle-Fu插件?

I have tried everything out and nothing seems to work.

我已经尝试了一切,似乎没有任何工作。

Note: assets_javascript & assets_css are both arrays of files that are pulled from a central location to keep this rake task and the view DRY.

注意:assets_javascript和assets_css都是从中心位置提取的文件数组,以保持此rake任务和视图DRY。

desc "Generate cached css/js files" 
task :asset_cache_generate => :environment do
    puts 'Caching Javascript & CSS Files'
    bundle do
        javascript_include_tag assets_javascript
        stylesheet_link_tag assets_css
    end
end

Thanks in advance for your help!

在此先感谢您的帮助!

- Tom

1 个解决方案

#1


The method bundle is mixed into ActionView so you can only call it from a templace instance.

方法包被混合到ActionView中,因此您只能从templace实例中调用它。

Unfortunately, you can't neither mix it into a custom class nor use it in a Rake task because it depends on many Rails template helpers/resources (concat, flash...). It would be too hard to reproduce all of them in order to make the method working.

不幸的是,你既不能将它混合到自定义类中,也不能在Rake任务中使用它,因为它依赖于许多Rails模板助手/资源(concat,flash ...)。为了使该方法有效,重现所有这些将太难了。

See http://github.com/timcharper/bundle-fu/blob/8056fd05c7ee4f637eb6137d544e91065400daab/lib/bundle_fu.rb

#1


The method bundle is mixed into ActionView so you can only call it from a templace instance.

方法包被混合到ActionView中,因此您只能从templace实例中调用它。

Unfortunately, you can't neither mix it into a custom class nor use it in a Rake task because it depends on many Rails template helpers/resources (concat, flash...). It would be too hard to reproduce all of them in order to make the method working.

不幸的是,你既不能将它混合到自定义类中,也不能在Rake任务中使用它,因为它依赖于许多Rails模板助手/资源(concat,flash ...)。为了使该方法有效,重现所有这些将太难了。

See http://github.com/timcharper/bundle-fu/blob/8056fd05c7ee4f637eb6137d544e91065400daab/lib/bundle_fu.rb