Giter Club home page Giter Club logo

Comments (10)

gazay avatar gazay commented on June 20, 2024

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.

dznz avatar dznz commented on June 20, 2024

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.

gazay avatar gazay commented on June 20, 2024

Fixed. Soon will be release of 4.0.0

from gon.

boom avatar boom commented on June 20, 2024

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.

dznz avatar dznz commented on June 20, 2024

@gazay thanks heaps for the partial (hurr) fix, in any case!

from gon.

dznz avatar dznz commented on June 20, 2024

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.

dznz avatar dznz commented on June 20, 2024

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.

gazay avatar gazay commented on June 20, 2024

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.

elsurudo avatar elsurudo commented on June 20, 2024

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.

gazay avatar gazay commented on June 20, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.