Modelo simples, se não estiver funcionando
Então, eu estou fazendo um simples se verificar um bool de uma estrutura, mas ele não parece funcionar, basta parar de renderizar o HTML.
Portanto, a seguinte estrutura é assim:
type Category struct {
ImageURL string
Title string
Description string
isOrientRight bool
}
Agora eu tenho uma fatia dessa estrutura de categoria que eu consigo exibir com um intervalo.
Abaixo está um exemplo de uma estrutura:
juiceCategory := Category{
ImageURL: "lemon.png",
Title: "Juices and Mixes",
Description: `Explore our wide assortment of juices and mixes expected by
today's lemonade stand clientelle. Now featuring a full line of
organic juices that are guaranteed to be obtained from trees that
have never been treated with pesticides or artificial
fertilizers.`,
isOrientRight: true,
}
Eu tentei várias maneiras, como abaixo, mas nenhuma delas funcionou:
{{range .Categories}}
{{if .isOrientRight}}
Hello
{{end}}
{{if eq .isOrientRight true}}
Hello
{{end}}
<!-- Print nothing -->
{{ printf .isOrientRight }}
{{end}}