Renderer::Links

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

The links renderer just renders a set of links, wrapped in a div, e.g.

<div class="my_dom_id">
  <a id="books" href="/books">Books</a>
  <a id="music" href="/musics" class="selected">Music</a>
  <a id="dvds" href="/dvds">Dvds</a>
</div>

The Links renderer works best for very simple, one level navigations where you don't need the extra HTML list tags (e.g. for a simple footer navigation).

To use this renderer call

render_navigation renderer: :links

You can pass the following options to render_navigation when using the links renderer:

  • :renderer - set to :links to use the links renderer
  • :join_with – to specify the character or string which should be used to join your links. The preferred way to visually separate your links is using CSS. Only use :join_with if you want a special character for separation. If you change this option, do not forget to also specify the whitespace around your join character, e.g. join_with: ' &#124; '. It’s safer to use escaped HTML characters when using special characters. You could even consider to escape the whitespace (join_with: '&amp;nbsp;&amp;#124;&amp;nbsp;').

Attention: Please be aware that the Links renderer does NOT render nested navigation. It only renders one level at a time. I.e. to render all the levels, you have to render them separately:

.primary= render_navigation renderer: :links, level: 1
.secondary= render_navigation renderer: :links, level: 2
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.