Registering Renderers

Simon Courtois edited this page May 2, 2014 · 5 revisions

Here's one way of creating and registering your own renderer.

  1. Create a folder in app/navigation_renderers
  2. Create your renderer and put it in there (e.g. my_custom_renderer.rb)
  3. Add it to the load path in config/application.rb (Rails 3 and 4) or config/environment.rb (Rails 2)
  4. Tell simple-navigation about your renderer in an initializer file, like config/initializers/simple_navigation.rb:
SimpleNavigation.register_renderer my_renderer: MyCustomRenderer

Then you can use the renderer in the render_navigation call:

#navigation= render_navigation renderer: :my_renderer

Or you can also use it without registering, just specify your class:

#navigation= render_navigation renderer: MyCustomRenderer