-
Notifications
You must be signed in to change notification settings - Fork 9
Generic Views
This page is up to date for Rango HEAD. The API was changed since 0.1, where everything was happening in Rango::GV
module.
If you have some repetitive tasks which can be shared across more controllers, you can use generic views to handle them. Classical example is when you just want to render a template. There is quite common that guys just have bunch of methods which do just render
. This is bad practice, and thanks to generic views, the only thing you have to do is route some URL to Rango::GV.static
.
This is how generic views works in Django. But in Rango, you can do more. You can for example include Rango::GV
in your controller and then use filters or even super to extend the view.
And then you can use Static.dispatcher(:static)
with your customized version of static
view.
As in the first example, just use Static.dispatcher(:static)
instead of Rango::GV.static
in your router.
Easy, right? In the block you can access to request
, use render
etc, it’s basically very similar to Rango::Controller
, but it’s more lightweight. If you need to customize it more, with filters for example, just include it into your controller as showed in example above.