Closed henrik closed 1 year ago
Explicitly adding the actionview
gem and requiring it fixes the issue: https://github.com/henrik/henrik.nyh.se/commit/b27f08d5c8db01fa6b8e914221a752580953faed
So the next step I suppose is to either automatically do this at some appropriate place in Slim (or Middleman or something) or documenting the requirement.
I'm experiencing the same problem.
Slim and Temple do not require ActionView and have fallbacks to other implementations if ActionView is not present.
The dependency comes from Middleman here:
This line explicitly requires ::Temple::Generators::RailsOutputBuffer
which requires ActionView::OutputBuffer
.
Right now it looks like the application is the component that decides that it will render slim templates using middleman and therefore has to include the action action_view gem.
Well researched! I guess the reason it worked fine on Slim 4 was that it would use an earlier version of Temple, pre this change: https://github.com/judofyr/temple/commit/de6468249618e28ef67b4dea6a048892c31cd8d7
@judofyr Any thoughts on this? I assume it would not be appropriate for Temple to add ActionView as a dependency.
Maybe let middleman choose a buffer type based on whether rails is available or not?
Maybe let middleman choose a buffer type based on whether rails is available or not?
I agree. Why does middleman depend on rails in the first place? That makes no sense to me.
Explicitly adding the
actionview
gem and requiring it fixes the issue
This did not work for me for some reason.
If I understand correctly this issue has been solved by adding action_view to the Gemfile as mentioned in https://github.com/slim-template/slim/issues/909#issuecomment-1435916165? Rails recommends to use ActionView::OutputBuffer
instead of ActiveSupport::SafeBuffer
for views, which caused this issue starting from Slim 5.0.
Thanks!
The issue was worked around from my point of view, and I’m a bit unclear on where it “should” be fixed – haven’t fully digested the comments above, but it seems to point to Middleman being the place. Either for a code change or “this is how you use it with Slim 5+” docs.
and I’m a bit unclear on where it “should” be fixed
I am too. One thing I am quite sure of - it does not need to be fixed in the user's side. This feels fragile. I had to add both the gem and a require 'action_view'
in my middleman's config.rb
.
Yes, ideally it would be documented in the middleman documentation. Is there some place where Slim is already mentioned? Otherwise we could also add a link to a working Middleman example with Slim to the Slim README. But generally I don't want to add Middleman-specifics here.
@tdreyno (of Middleman), can I ask you for your thoughts?
If it is solved via docs, I guess one or both of these places could make sense:
Isn't it possible to solve it rather than documenting it? It is very rare that users are requested to "bring their own indirect dependencies", especially when it will not work without them.
@DannyBen
Isn't it possible to solve it rather than documenting it? It is very rare that users are requested to "bring their own indirect dependencies", especially when it will not work without them.
Slim doesn't depend on Rails, but provides integration. We cannot depend on it here. If you want to solve the dependency issue, it must be done in Middleman.
If you want to solve the dependency issue, it must be done in Middleman.
Thanks. Yes, I realize that. I was responding to the comment above, who called for Middleman guys into the discussion.
Yes, I pinged them for their thoughts on how to solve it, ideally, and documenting only as a fallback solution. Thus the "If it is solved via docs".
Looks like https://github.com/middleman/middleman/issues/2619 is the appropriate place to continue the discussion?
Looks like https://github.com/middleman/middleman/issues/2619 is the appropriate place to continue the discussion?
Isn't it a different issue?
No, looks to be about the same thing to me
I tried using Slim 5 with Middleman and got an error when I visited a page (not when Middleman boots, but when it attempts to render a template).
Slim 4 works fine.