ruby on rails - Best way to output a tag who's name is dynamically created? -
In my rail application, I'm partly called partly.
Partial I want to output a & lt; H1 & gt;
, & lt; H2 & gt;
, & lt; H3 & gt;
... Depending on the level (definitely cap on level 6)
Something like this:
------- & gt; & Lt;% open_h (1)% & gt; & Lt; P & gt; & Lt;% = ...% & gt; & Lt; / P & gt; & Lt;% books.each do | Book | & Gt%; ... & lt;% end% & gt; & Lt;% close_h (1)% & gt;
For now, I have cut two tasks together as helpers, but what is the best way to do this really?
Post-text "itemprop =" text ">
You can do something like
# _book.html .rb <% content_tag" h # {Level} "do this> gt; & lt; p & gt; & lt;% = ...% & gt; & lt; / p & gt; & lt;% if level & lt; 6% & gt; & Lt;% = Render: collection = & gt; Books ,: local = & gt; {: Level = & gt; Level + 1} & lt;% end% & gt; & lt;% end% & gt; # Action.html. ARB & lt;% = Render: Partial = & gt;: Book, Collection = & gt; @ Books, Local = & gt; {: Level = & gt; 0}% & gt;
Comments
Post a Comment