Make a Curly presenter wrap its own view in content_for?
pgrosvenor opened this issue · 3 comments
Is there a way to make a Curly presenter wrap the view it is presenting in content_for?
I have looked at having content_for in a super! method but that seems to be for yielding individual attributes elsewhere like @object.title rather than the whole view? Currently as a (terrible) work around we have an empty view that calls a presenter with a setup! content_for method that calls a second view with all the logic that ‘should' be in the first view. Hopefully there is a better solution?
Thanks for making Curly and thanks in advance for looking into this.
Hmm, that's a tricky one. It would basically have to change the way the entire view is rendered based on some magic method (?) or something. Is there a syntax you have in mind?
I usually just add a basic ERb view that does the wrapping:
<% content_for(:something) { render 'something_else' } %>
Depending on how much data you need to forward, it may be simpler and easier to follow like that.
To be honest I don't have a good idea for how the syntax could be and actually I am probably just over-complicating our original problem anyway. I think you're right that the best solution here is just a normal ERb view with a content_for.
Thanks for having a look at it anyway.
No problem – I've been through some of the same contemplations. Usually it's better to use a less magic approach.