Code Monkey home page Code Monkey logo

Comments (16)

jacquescrocker avatar jacquescrocker commented on July 17, 2024

hmm, maybe its worth adding another declaration (instead of object)

collection @users, :users

from rabl.

nesquena avatar nesquena commented on July 17, 2024

Yeah there will be settings controlling all of this stuff very soon. I agree it should be configurable.

from rabl.

nesquena avatar nesquena commented on July 17, 2024

I would probably create collection @users => :users to match the syntax in other declarations. Does that work? And then add configurations for collection root node "users": { } and object root node on a project level basis. I also probably need a way to tweak those on a per template basis?

from rabl.

jacquescrocker avatar jacquescrocker commented on July 17, 2024

sure, that sounds great

from rabl.

nesquena avatar nesquena commented on July 17, 2024

Thanks for the suggestion

from rabl.

jacquescrocker avatar jacquescrocker commented on July 17, 2024

turns out ExtJS its easy to get it to use the original format as well (using record: 'user' option). so that solved my issue but i'll be happy to test the new collection syntax option once its working

thanks

from rabl.

nesquena avatar nesquena commented on July 17, 2024

Thanks, Can you help me design the configuration options dsl. I was thinking to take a lesson from the way tequila did it:

object @user
initial_label true 
# adds { users : [{ user : { first_name : "..."  }, ...] }

and then

item_label false 
# changes it to  [{ first_name : "..." }, ...]

but it doesn't feel all that clean. Do you have any suggestions. Can you think of other options that might need to be configurable?

from rabl.

jacquescrocker avatar jacquescrocker commented on July 17, 2024

yeah, initial_label does sound kind of weird. I'd recommend root_name. I do like the idea of having the false value return the value directly

from rabl.

nesquena avatar nesquena commented on July 17, 2024

Another option could be simply an options hash on the 'object' or 'collection':

object @user, :initial_label => true, :item_label => false

Not sure if this is better or worse and then I would probably need it for child too?

child :users, :initial_label => true, :item_label => false do
  attributes :first_name
end

from rabl.

jacquescrocker avatar jacquescrocker commented on July 17, 2024

ah, good point. object @user => :user seems like the best option. then it'd be the same as for a collection

if its nil, it should use intelligent defaults as it does now (using the model_name) which is very cool

from rabl.

nesquena avatar nesquena commented on July 17, 2024

Ah interesting so basically:

root_name false # { user : {...} }
root_name 'users' # { users : { user : {} }

That could work? But how would I mention to remove the inner 'object' name if you wanted:

{ users : [...] }

Once I figure out the cleanest syntax, implementing this will be trivial.

from rabl.

jacquescrocker avatar jacquescrocker commented on July 17, 2024

i'll hop on IRC :-)

from rabl.

nesquena avatar nesquena commented on July 17, 2024

Ok so basically:

object @user => :user 
# => { user : {...} }

and

collection @users => :users
# => { 'users' : { 'user' : {...} } }

I am still not sure how I would allow the other permutation:

{ 'users' : { "first_name" : "..." }  }

Is this second way where the item has no "user" root node in a collection your preferred output?

from rabl.

nesquena avatar nesquena commented on July 17, 2024

I actually have to go. Ill be on IRC later, maybe we can design this then.

from rabl.

jacquescrocker avatar jacquescrocker commented on July 17, 2024

cool, i'll think about it and catch up with you soon on IRC. my nick is jacquesc

thanks

from rabl.

nesquena avatar nesquena commented on July 17, 2024

Final issue left for this is: #4

Right now you can do:

object @user => :person
collection @users => :people

and it will add a root node "people" BUT there will still be a "person" label inside for every person i.e:

{  "people" : [  { "person" : { age : 22 }  } ] }

That is how I prefer it, but I can see the need for the other way:

 {  "people" : [ { age : 22 } ] }

Currently that way isn't possible.

from rabl.

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.