I am building a rack middleware (to work within rails) that wants to use javascript_include_tag from within the rack middle ware.
How can I call javascript_include_tag outside of the controller/view context.
I guess even this title is a bit to detailed. All I want to do is get the correct link to some asset from within a rack middleware.
To put it at the highest level I can: Need to have rack middleware get the link to the sprockets generated asset for a given file.
Why? Well I guess that is my business, but its for a gem I maintain that creates a test page that you can then use rspec/capybara to interact with assets on that page. This allows unit testing of the assets without relying on the specific context on some layout or view.
Currently I provide this capability by having the gem dynamically create a controller, and then hacking around in the rails route. All works fine, but it just seems like its calling out for a simple rack middle ware that will handle the test url.
Also this means I have separate code to deal with non-rails environments (i.e. Sinatra) . It would be nice if the only dependency were sprockets and rack.
question from:
https://stackoverflow.com/questions/65919939/call-javascript-include-tag-within-a-rack-middleware 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…