-
i want to dynamically add a class to an item, like this: templ CourseCard(course obsidian.Course) {
<div class="coursecard card-color-{course.Color}">
{ course.Name }
</div>
} where course.Color is red, blue, etc. But then it doesn't get properly formatted and i just end up with a class literally called |
Beta Was this translation helpful? Give feedback.
Answered by
a-h
Sep 27, 2024
Replies: 1 comment
-
Something like this should work: type Course struct {
Name string
Color string
}
templ button(text string, course Course) {
<button class={ "coursecard", fmt.Sprintf("card-color-%s", course.Color) }>{ text }</button>
} |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
Tesohh
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Something like this should work: