-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ActionView::Template::Error: stack level too deep #33
Comments
Hmm no, this should word because |
@ccocchi : this is definitely a bug. Try to define in a rabl template 'items/show.rabl' : object @resource
condition(->(item) { false }) do
extends 'items/show'
end It will raise :
Looks like the block is executed even if the condition is false. In fact the block won't be displayed if the condition is false but will nevertheless be executed. |
You're right, condition body are evaluated at compilation time so it will raise, but it is not a bug. You're trying to introduce a circular reference which is never a good idea, and is often due to a bad design so it won't be added to You can resolve your issue by extracting into a partial everything you will need in your x template from y template, and include it once in your y template and once in your x template inside your condition body. This way you will never a case of circular reference, which is a lot safer in my opinion. |
I can't see a problem on using circular references when you have a clear "breakpoint". As far as I know, most recursive algorithms work based on this premise. You should only be careful ensuring there's always a "breakpoint". In my opinion, recursive structures are not necessarily bad design. It might be the case that they're a requirement. I'm trying to create a recursive JSON structure of comments within comments, but I'm getting the same problem that abrisse got. |
You're right, it makes sense when you're doing recursive templates, but that's different from what @abrisse was trying to achieve. At the moment you won't be able to use But we could imagine a new directive |
When migrating from
rabl
torabl-rails
I encounter a problem. Let's say you have 2 views in which you can extends each other under 2 different conditions that cannot be true at the same time.Postulate : condition_A = !condition_B
That case triggers a ActionView::Template::Error: stack level too deep error when rendered. I guess that because the views are compiled contrary to the
rabl
gems.The text was updated successfully, but these errors were encountered: