Full demo
This commit is contained in:
@ -2,14 +2,61 @@ package handlers
|
||||
|
||||
import (
|
||||
"templ-tests/app/templates"
|
||||
"templ-tests/app/types"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
var catFacts []types.CatFact = []types.CatFact{
|
||||
{
|
||||
Breed: "Abyssinian",
|
||||
Country: "Ethiopia",
|
||||
Origin: "Natural/Standard",
|
||||
Coat: "Short",
|
||||
Pattern: "Ticked",
|
||||
},
|
||||
{
|
||||
Breed: "Aegean",
|
||||
Country: "Greece",
|
||||
Origin: "Natural/Standard",
|
||||
Coat: "Semi-long",
|
||||
Pattern: "Bi- or tri-colored",
|
||||
},
|
||||
{
|
||||
Breed: "American Curl",
|
||||
Country: "United States",
|
||||
Origin: "Mutation",
|
||||
Coat: "Short/Long",
|
||||
Pattern: "All",
|
||||
},
|
||||
{
|
||||
Breed: "American Bobtail",
|
||||
Country: "United States",
|
||||
Origin: "Mutation",
|
||||
Coat: "Short/Long",
|
||||
Pattern: "All",
|
||||
},
|
||||
{
|
||||
Breed: "American Shorthair",
|
||||
Country: "United States",
|
||||
Origin: "Natural",
|
||||
Coat: "Short",
|
||||
Pattern: "All but colorpoint",
|
||||
},
|
||||
{
|
||||
Breed: "American Wirehair",
|
||||
Country: "United States",
|
||||
Origin: "Mutation",
|
||||
Coat: "Rex",
|
||||
Pattern: "All but colorpoint",
|
||||
},
|
||||
}
|
||||
|
||||
func About(c *gin.Context) {
|
||||
pc := templates.PageContext{
|
||||
Title: "Welcome to the demo - About",
|
||||
ActivePage: "about",
|
||||
}
|
||||
templates.About(pc).Render(c, c.Writer)
|
||||
|
||||
templates.About(pc, catFacts).Render(c, c.Writer)
|
||||
}
|
||||
|
||||
@ -2,14 +2,21 @@ package handlers
|
||||
|
||||
import (
|
||||
"templ-tests/app/templates"
|
||||
"templ-tests/app/types"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func Home(c *gin.Context) {
|
||||
user := types.User{
|
||||
FirstName: "Pero",
|
||||
LastName: "Perić",
|
||||
}
|
||||
|
||||
pc := templates.PageContext{
|
||||
Title: "Welcome to the demo",
|
||||
ActivePage: "home",
|
||||
User: &user,
|
||||
}
|
||||
templates.Home(pc, "World").Render(c, c.Writer)
|
||||
templates.Home(pc).Render(c, c.Writer)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user