-
-
Couldn't load subscription status.
- Fork 31
Open
Description
So I'm making a personal blog site (surprise), and I wanted to add post tags. No problem, i'll add a field to my struct real quick.
#[derive(Content)]
pub struct Post {
//...
pub tags: Vec<String>
}Now to make a row of links to each tag. Let's see.
{{#tags}}<a href="/post/tag/{{ ? }}">{{ ? }}</a> {{/tags}}...I'm not sure how to name each item in the Vec. The section repeats 3 times if there are 3 elements in the Vec, but I don't know how to actually refer to the element, to make the sections different.
I was able to solve it using a tuple struct, just because I can name the field 0, like this.
#[derive(Content)]
pub struct Post {
//...
pub tags: Vec<Tag>
}
#[derive(Content, Clone, PartialEq, Eq, Hash, Default, Debug)] //idk im not used to tuple structs
pub struct Tag(String);{{#tags}}<a href="/post/tag/{{0}}">{{0}}</a> {{/tags}}I'm a little bummed that I needed a useless tuple struct for this though. Is there a nicer way to do this?
Metadata
Metadata
Assignees
Labels
No labels