From 551fcee088138b26dba09f11c75ec01682cab5fd Mon Sep 17 00:00:00 2001 From: Nulo Date: Wed, 10 Nov 2021 10:43:06 -0300 Subject: [PATCH] Reutilizar template de mostrar NFT y mostrar nombres en index --- main.go | 4 ++-- templates/embed-nft.tmpl | 7 +++++++ templates/index.tmpl | 10 +++------- 3 files changed, 12 insertions(+), 9 deletions(-) create mode 100644 templates/embed-nft.tmpl diff --git a/main.go b/main.go index ad72845..d515c52 100644 --- a/main.go +++ b/main.go @@ -160,9 +160,9 @@ func must(err error) { } func main() { - indexTmpl, err := template.ParseFiles("./templates/base.tmpl", "./templates/index.tmpl") + indexTmpl, err := template.ParseFiles("./templates/base.tmpl", "./templates/embed-nft.tmpl", "./templates/index.tmpl") must(err) - nftsTmpl, err := template.ParseFiles("./templates/base.tmpl", "./templates/nft.tmpl") + nftsTmpl, err := template.ParseFiles("./templates/base.tmpl", "./templates/embed-nft.tmpl", "./templates/nft.tmpl") must(err) http.Handle("/static/nfts/", http.StripPrefix("/static/nfts/", http.FileServer(http.Dir(NFTS_DIR)))) diff --git a/templates/embed-nft.tmpl b/templates/embed-nft.tmpl new file mode 100644 index 0000000..5eb631a --- /dev/null +++ b/templates/embed-nft.tmpl @@ -0,0 +1,7 @@ +{{define "embed-nft"}} +{{if .IsVideo}} + +{{else}} + +{{end}} +{{end}} diff --git a/templates/index.tmpl b/templates/index.tmpl index 5f59f21..04e3d7c 100644 --- a/templates/index.tmpl +++ b/templates/index.tmpl @@ -10,14 +10,10 @@

Algunos NFTs descargados

{{range .NFTs}}
- - {{if .IsVideo}} - - {{else}} - - {{end}} - +

{{.Asset.Name}}

+ {{template "embed-nft" .}}
+
{{end}} {{end}}