I’m trying to add the list of tags for a post to an HTML attribute. Something like this:
{{#get "posts" include="tags"}}
<ul>
{{#foreach posts}}
<li class="{{tags}}">{{title}}</li>
{{/foreach}}
</ul>
{{/get}}
The issue is that the {{tags}} helper returns links, not plain text. (It’s a helper, yes? still working on Handlebars terminology!)
Thanks!
Hey @dan.2rational,
Just want to clarify if it’s all the tags from the site you want, or all the tags from a single post? Either way we’ve got some pretty good documentation on our site for working with tags:
Let us know what specifically you want to do
Hi David!
Thanks for responding - I’m looking to do the tags for each post as the class attributes for the list item, using the example above.
The full example is building a grid with UIKit that can then be filtered - each element in the grid is a list item, and the classes on the list item enabling the filtering.
Thanks!
Ah I see, thanks for the clarification Dan. Something like this should work:
{{#foreach posts}}
<li class="{{#foreach tags}} {{slug}}{{/foreach}}">{{title}}</li>
{{/foreach}}
@DavidDarnes Thank you! That got it!
1 Like