inline_svg icon indicating copy to clipboard operation
inline_svg copied to clipboard

Set asset finder from callable

Open xymbol opened this issue 2 years ago • 4 comments

It fixes #151 by allowing the asset finder to be a callable object. This is useful when the asset pipeline is not ready when the initializer is run, for example, when using Propshaft.

I don't know if this is the best way to solve this problem. On the one hand, Propshaft could be done when its initializer is run, but on the other hand, this gem's railtie assumes the asset pipeline is ready.

xymbol avatar Oct 24 '23 02:10 xymbol

Hi guys! Just wanted to let you know - right now, the only way it works for me with Propshaft, is if I add this:

# config/initializers/inline_svg.rb
InlineSvg.configure do |config|
  config.asset_finder = InlineSvg::PropshaftAssetFinder
end

yshmarov avatar Oct 24 '23 21:10 yshmarov

… right now, the only way it works for me with Propshaft, is if I add this…

@yshmarov So, this branch does not work with your app? Did you change the order in your Gemfile, as mentioned in #151?

I have a Propshaft app working with this change. Still, I'm unconvinced by the initializer approach and would rather have a set of strategies to detect the asset pipeline lazily.

I'd be happy to explore that.

xymbol avatar Oct 25 '23 00:10 xymbol

@jamesmartin I drafted a more flexible approach in #155, which still needs to be completed, where we don't rely on the initializer and lazily detect which asset finder adapter matches the environment unless the user sets one explicitly.

I can clean up and mark either one as ready for review, depending on your preference.

xymbol avatar Oct 27 '23 18:10 xymbol

Thanks for continuing to push this forward. I haven't had the chance to properly think about the implications of this change. I'll try to get back to you soon.

jamesmartin avatar Oct 30 '23 00:10 jamesmartin

This is still an issue. Should we add this work around to the documentation or reopen this pull request?

justinallenmarsh avatar Oct 12 '24 10:10 justinallenmarsh