In my Rails application I have a partial which is called recursively.
In the partial I want to output a <h1>
, <h2>
, <h3>
... depending on the level. (Cap at level 6, of course)
Something like this:
<h1>
<p><%= ... %></p>
<% books.each do |book| %>
...
<% end %>
</h1>
------->
<% open_h(1) %>
<p><%= ... %></p>
<% books.each do |book| %>
...
<% end %>
<% close_h(1) %>
For now I hacked together the two functions as helpers, but is that really the most elegant way to do this?