@apotonick, maybe you want to be mentor for this idea? ;)
iirc, we still waiting for https://github.com/rtomayko/tilt/pull/107 to adopt Tilt in Rails, maybe fine add this as another idea for GSoC?
Ok, so as I understand it the objective would be to remove "the interface between ActionController and ActionView" (the article provides 4 points on how this interface is defined). Removing this interface would allow you to support multiple interfaces to generate views with instead of being forced to use ActionView with ActionController. Did I understand that correctly?
av.render("path/to/template", locals, context)
rails_tilt_instance.render("path/to/template", locals, context)
I have a couple of ideas for how views could be improved. Talking with Nick Sutterer, however, it seems that a lot of what I'm proposing overlaps with the functionality of cells. Here's my proposal: https://gist.github.com/wangjohn/09f054c15d777997242a. I'm still thinking of ideas and trying to flesh out more thoughts.
The hardest problem to solve is how to deal with view paths. Logically you should just pass the template path to the renderer and then it should find the template that best matches that path. This means moving a bunch of code dealing with layout/template inheritance into Action View which is likely to be very messy.
The ActionController::Renderers code would also need to be moved to Action View so that it's responsible for handling the `render :xml => @model` options.
The hardest problem to solve is how to deal with view paths. Logically you should just pass the template path to the renderer and then it should find the template that best matches that path. This means moving a bunch of code dealing with layout/template inheritance into Action View which is likely to be very messy.I agree with this. This is one of the responsibilities shared by both controllers and views. Views need to look for templates to render them (for example, a partial, or any kind of rendering, really). Controllers needs to look for templates too, in order to set the proper response content type.To complicate matters, Rails considers many factors when looking up for a template:* The view paths registered in the controller* The request format and locale* The controller prefixes (like users for UsersController)
Well, shouldn't the whole lookup happen in the controller, which knows best about view paths, inheritance and request formats? It would just pass this information to AV which can still provide the rendering by exposing the proposed #render API?!?!
Well, shouldn't the whole lookup happen in the controller, which knows best about view paths, inheritance and request formats? It would just pass this information to AV which can still provide the rendering by exposing the proposed #render API?!?!
I meant to say: the lookups can happen in AV as well but the informations needed (suffixes, paths, inheritance, prefixes) should be passed from the controller which knows best about these things.
AV.new(suffixes, prefixes, paths).render(template_name, locals)
Well, this is pretty much what we have today:ViewRenderer.new(lookup_context).render(view_context, options)
The current API should be able to be tweaked quite easily - you have view_renderer, view_context_class and view_context which is an instance of view_context_class. There should be a configuration mechanism which allows a gem's Railtie to setup these values and then it's just a case of the view_renderer supporting `render(view_context, options)`. The view_context_class needs to accept the view_renderer, view_assigns and controller instance in its initialize method. The ActionController::Renderers code would also need to be moved to Action View so that it's responsible for handling the `render :xml => @model` options.