writing an ERB template for inline_indexterm

Previous Topic Next Topic
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

writing an ERB template for inline_indexterm

I'm trying to write a custom template in ERB for index terms, but I'm having trouble making it work.

If I run Asciidoctor without an indexterm template, the primary, secondary, tertiary, see, and see-also all work out of the box. But I can't figure out how to call any of them in my template. I would think I should be able to do something like this:

<indexterm><primary><%= attr :primary %></primary>
<% if attr? :secondary %><secondary><%= attr :secondary %></secondary><% end %>
<% if attr? :tertiary %><tertiary><%= attr :tertiary %></tertiary><% end %>
<% if attr? :see %><see><%= attr :see %></see><% end %>
<% if attr? :see_also %><seealso><% attr :seealso %></seealso><% end %>

I haven't been able to find a variation of this that works. I can call attr: terms but that gives me the entire list of terms, which is not what I want.

I've only been able to find one real example of an inline_indexterm template to use as reference, but it includes all of the Ruby script for breaking the terms list into primary/secondary/etc:

Am I missing something simple here? Or do I need to put the full Ruby script into my template in order to get it to work?