Comments (10)
Thank you for response!
All clear here, I'll fix it right when have some time to do opensource) Hope will do it soon.
from gon.
Thanks! Sorry I couldn't submit a patch for it, wasn't quite sure what else Gon was doing, and how to ensure the context was setup correctly.
from gon.
Fixed. Soon will be release of 4.0.0
from gon.
This is still not fully fixed. Partials only works with jbuilder syntax that specify directory and passed variable:
json.comments @comments do |json, comment|
json.partial! 'comments/comment', :comment => comment
end
But will not work with alternative short hand syntax for jbuilder that uses default folder structure and file naming (assuming same files and folders as specified above):
json.comments @comments do |json, comment|
json.partial! comment
end
from gon.
@gazay thanks heaps for the partial (hurr) fix, in any case!
from gon.
I'm looking at 7c05c6e and I don't want to be nit-picky, but should Gon be parsing the partials at all? Seems to me like Gon should set up the environment and then delegate directly to jbuilder and let it do all the partial resolving.
Otherwise you are basically going to be stuck re-implementing jbuilder's code, with bugs turning up every time Gon's approach differs from jbuilder's approach. I reckon @mroseboom's issue might be solved in this approach.
I recognise that "set up the environment" is pretty hand-wavey, and ultimately there might be a good reason not to do it this way, but I'd be interested to know your thoughts.
from gon.
An example: I'd like to do this in a controller:
@widgets = current_user.widgets
gon.jbuilder template: "app/views/widgets/index.json.jbuilder", as: "widgets"
Where widgets/index.json.jbuilder
looks like:
json.array!(@widgets) do |json, widget|
json.partial! "widgets/widget", widget: widget
end
and widgets/_widget.json.jbuilder
looks like this:
json.(widget, :id, :name, :label)
But when I try it, I get: undefined local variable or method 'workout' for Gon::Jbuilder:Module
.
I'm pretty sure this is a parsing bug, but I'd rather see Gon lean on jbuilder for parsing than have it patched in Gon, if you take my meaning.
Not sure if this helps!
from gon.
I'm sorry, but I'll be on vacation soon. So if you'll do some research and do pull request - it will be super great!))
I want to comeback to maintain this gem after vacation - 2-3 weeks, but I glad that you use this gem and try to find some capabilities to use it :) If you'll share to me your experience of usage this gem I'll can do my work better
Thank you)
from gon.
Having the same issue over here, so this was never fixed? @gazay is there any particular reason that gon does its own parsing of the partials? It seems to me that that should be left to the jbuilder (or rabl, etc.) gem itself...
from gon.
Because of architecture of jbuilder. It is replaces flow of usual rendering, so it allow you to render only once through controller action. That's why I have to partially replace jbuilder functionality (in Rabl I can simply call Rabl::Engine#render method). But it was a year ago - maybe now there is a different situation and if you can help with research - it will be super awesome.
Anyway thank you that you somehow interested in gon and find time to write me some response!
from gon.
Related Issues (20)
- use from engine HOT 2
- Gon variable "undefined" when nested in a format.js statement
- Any thoughts on ways to make gon play nicely with webpacker? HOT 4
- gon.watch not update variable in different browser windows.
- Write to localstorage
- How to use Base64.urlsafe_decode64 for a gon variable.
- json.cache! is not working when using gon.jbuilder HOT 1
- Is there a way to update gon through a remote call (JS)? HOT 1
- How to use CSP `nonce` option with Rails 5.2? HOT 3
- A new version possible? HOT 2
- NoMethodError: undefined method `create' for ActionDispatch::TestRequest:Class with rails 4
- Problem gon navigate with turbolinks HOT 2
- Is there a way to set gon variables with a proc? HOT 1
- Option to print variables one per line HOT 2
- Cannot access Rails view helpers methods when using with JBuilder HOT 1
- test failure with rails 6 - Gon#include_gon outputs correct js with a script string
- undefined variable include_gon HOT 1
- Array attribute types incorrectly rendered with Jbuilder using key_format! option
- Why do my objects only contain ID strings after transmitting via gon? HOT 2
- ArgumentError - tried to create Proc object without a block
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gon.