ccocchi / rabl-rails

Rails 4.2+ templating system with JSON, XML and Plist support.
MIT License
209 stars 51 forks source link

Any plans of merging to the original rabl gem? #53

Closed tispratik closed 6 years ago

tispratik commented 10 years ago

Is rabl-rails still 20% faster than rabl? If so what is the secret sauce :+1: Can we merge the same into rabl gem?

It feels that everyone should have only one gem to goto and contribute.

Thanks!

ccocchi commented 10 years ago

Unfortunately, I think a merging will not be possible, at least not in a close future.

Before doing this gem, I tried to modify the rabl gem but it was too complex and was not working as I wanted. I started from scratch and used a totally different approach (hence the performance gain) so it would be diffcult to merge this back to the original gem.

Moreover, the original gem supports a lot of frameworks (while this gem only focus on rails) and a lot of features have not been port back yet in this gem, adding more complexity to the merge.

tispratik commented 10 years ago

Okay. thanks Christopher. That is good to know. Maybe we can add a reason in readme so that people realize why there are two forks?

On Mon, Feb 24, 2014 at 3:29 AM, Christopher Cocchi-Perrier < notifications@github.com> wrote:

Unfortunately, I think a merging will not be possible, at least not in a close future.

Before doing this gem, I tried to modify the rabl gem but it was too complex and was not working as I wanted. I started from scratch and used a totally different approach (hence the performance gain) so it would be diffcult to merge this back to the original gem.

Moreover, the original gem supports a lot of frameworks (while this gem only focus on rails) and a lot of features have not been port back yet in this gem, adding more complexity to the merge.

Reply to this email directly or view it on GitHubhttps://github.com/ccocchi/rabl-rails/issues/53#issuecomment-35877626 .

razum2um commented 10 years ago

I'm looking around both gems and seems like original Rabl gem suffer from extends problem, and the author points to here https://github.com/nesquena/rabl/issues/500#issuecomment-26454368

Moreover, in the same thread they discuss preprocessing step, too :smile: https://github.com/nesquena/rabl/issues/500#issuecomment-30891223

ccocchi commented 10 years ago

Yes rabl suffers from extends and rendering large collection. It is caused by the fact that the rabl gem uses instance_eval on each file (more accurately on each source code in these files) each time you're trying to render an object. This allows to include syntax like if, unless in templates whereas in rabl-rails template, you would use lambdas to achieve the same thing.

In the other hand, rabl-rails templates are compiled (meaning instance eval'd) once into ruby code, independently of the object being rendered. Thus rendering an object, is just using this ruby code (a hash in v0.3, a collection of nodes in v0.4) and is a lot faster than using intance_eval.