Merge branch 'htmx-playground'

This commit is contained in:
Eden Kirin
2024-01-21 18:09:11 +01:00
12 changed files with 1487 additions and 251 deletions

679
app/data/catbreeds.go Normal file
View File

@ -0,0 +1,679 @@
package data
import "templ-tests/app/types"
var CatBreeds []types.CatBreed = []types.CatBreed{
{
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",
},
{
Breed: "Arabian Mau",
Country: "Arabian Peninsula",
Origin: "Natural",
Coat: "Short",
Pattern: "",
},
{
Breed: "Australian Mist",
Country: "Australia",
Origin: "Crossbreed",
Coat: "Short",
Pattern: "Spotted and Classic tabby",
},
{
Breed: "Asian",
Country: "United Kingdom",
Origin: "",
Coat: "Short",
Pattern: "Evenly solid",
},
{
Breed: "Asian Semi-longhair",
Country: "United Kingdom",
Origin: "Crossbreed",
Coat: "Semi-long",
Pattern: "Solid",
},
{
Breed: "Balinese",
Country: "United States",
Origin: "Crossbreed",
Coat: "Long",
Pattern: "Colorpoint",
},
{
Breed: "Bambino",
Country: "United States",
Origin: "Crossbreed",
Coat: "Hairless/Furry down",
Pattern: "",
},
{
Breed: "Bengal",
Country: "United States",
Origin: "Hybrid",
Coat: "Short",
Pattern: "Spotted/Marbled",
},
{
Breed: "Birman",
Country: "France",
Origin: "Natural",
Coat: "Semi Long",
Pattern: "Colorpoint",
},
{
Breed: "Bombay",
Country: "United States",
Origin: "Crossbred",
Coat: "Short",
Pattern: "Solid",
},
{
Breed: "Brazilian Shorthair",
Country: "Brazil",
Origin: "Natural",
Coat: "Short",
Pattern: "All",
},
{
Breed: "British Semi-longhair",
Country: "United Kingdom",
Origin: "",
Coat: "Medium",
Pattern: "All",
},
{
Breed: "British Shorthair",
Country: "United Kingdom",
Origin: "Natural",
Coat: "Short",
Pattern: "All",
},
{
Breed: "British Longhair",
Country: "United Kingdom",
Origin: "",
Coat: "Long",
Pattern: "",
},
{
Breed: "Burmese",
Country: "Burma and Thailand",
Origin: "Natural",
Coat: "Short",
Pattern: "Solid",
},
{
Breed: "Burmilla",
Country: "United Kingdom",
Origin: "Crossbreed",
Coat: "Short/Long",
Pattern: "",
},
{
Breed: "California Spangled",
Country: "United States",
Origin: "Crossbreed",
Coat: "Short",
Pattern: "Spotted",
},
{
Breed: "Chantilly-Tiffany",
Country: "United States",
Origin: "",
Coat: "",
Pattern: "",
},
{
Breed: "Chartreux",
Country: "France",
Origin: "Natural",
Coat: "Short",
Pattern: "Solid",
},
{
Breed: "Chausie",
Country: "France",
Origin: "Hybrid",
Coat: "Short",
Pattern: "Ticked",
},
{
Breed: "Cheetoh",
Country: "United States",
Origin: "Hybrid Crossbreed",
Coat: "Short",
Pattern: "Spotted",
},
{
Breed: "Cornish Rex",
Country: "United Kingdom (England)",
Origin: "Mutation",
Coat: "Rex",
Pattern: "All",
},
{
Breed: "Cymric or Manx Longhair",
Country: "United Kingdom (Isle of Man)",
Origin: "Natural/Mutation",
Coat: "Long",
Pattern: "",
},
{
Breed: "Cyprus",
Country: "Cyprus",
Origin: "Natural",
Coat: "All",
Pattern: "All",
},
{
Breed: "Devon Rex",
Country: "United Kingdom (England)",
Origin: "Mutation",
Coat: "Rex",
Pattern: "All",
},
{
Breed: "Donskoy, or Don Sphynx",
Country: "Russia",
Origin: "",
Coat: "Hairless",
Pattern: "",
},
{
Breed: "Dragon Li",
Country: "China",
Origin: "Natural",
Coat: "Short",
Pattern: "Striped tabby",
},
{
Breed: "Dwarf cat, or Dwelf",
Country: "",
Origin: "Crossbreed",
Coat: "",
Pattern: "Hairless",
},
{
Breed: "Egyptian Mau",
Country: "Egypt",
Origin: "Natural",
Coat: "Short",
Pattern: "Spotted",
},
{
Breed: "European Shorthair",
Country: "Finland and Sweden",
Origin: "Natural",
Coat: "Short",
Pattern: "",
},
{
Breed: "Exotic Shorthair",
Country: "United States",
Origin: "Crossbreed",
Coat: "Short",
Pattern: "All",
},
{
Breed: "Foldex[4]",
Country: "Canada",
Origin: "Crossbreed",
Coat: "Short",
Pattern: "All",
},
{
Breed: "German Rex",
Country: "East Germany",
Origin: "Mutation",
Coat: "Rex",
Pattern: "",
},
{
Breed: "Havana Brown",
Country: "United Kingdom",
Origin: "",
Coat: "Short",
Pattern: "Solid",
},
{
Breed: "Highlander",
Country: "United States",
Origin: "Crossbreed",
Coat: "Short/Long",
Pattern: "All",
},
{
Breed: "Himalayan, or Colorpoint Persian",
Country: "United States/United Kingdom",
Origin: "Crossbreed",
Coat: "Long",
Pattern: "Colorpoint",
},
{
Breed: "Japanese Bobtail",
Country: "Japan",
Origin: "Natural",
Coat: "Short/Long",
Pattern: "All but colorpoint and ticked",
},
{
Breed: "Javanese",
Country: "United States",
Origin: "Crossbreed",
Coat: "Long/Short",
Pattern: "Colorpoint",
},
{
Breed: "Karelian Bobtail",
Country: "Western Russia",
Origin: "Natural",
Coat: "",
Pattern: "",
},
{
Breed: "Khao Manee",
Country: "Thailand",
Origin: "Natural",
Coat: "Short",
Pattern: "Solid",
},
{
Breed: "Korat",
Country: "Thailand",
Origin: "Natural",
Coat: "Short",
Pattern: "Solid",
},
{
Breed: "Korean Bobtail",
Country: "Korea",
Origin: "Natural",
Coat: "Short/Long",
Pattern: "Colorprint",
},
{
Breed: "Korn Ja",
Country: "Thailand",
Origin: "Natural",
Coat: "Short/Hairless",
Pattern: "Solid",
},
{
Breed: "Kurilian Bobtail, or Kuril Islands Bobtail",
Country: "Eastern Russia,Japan",
Origin: "Natural",
Coat: "Short/Long",
Pattern: "",
},
{
Breed: "LaPerm",
Country: "United States",
Origin: "Mutation",
Coat: "Rex",
Pattern: "All",
},
{
Breed: "Lykoi",
Country: "United States",
Origin: "Natural/Mutation",
Coat: "Partly Hairless",
Pattern: "Ticked",
},
{
Breed: "Maine Coon",
Country: "United States",
Origin: "Natural",
Coat: "Long",
Pattern: "All but colorpoint and ticked",
},
{
Breed: "Manx",
Country: "United Kingdom (Isle of Man)",
Origin: "Mutation",
Coat: "Short/Long",
Pattern: "All but colorpoint",
},
{
Breed: "Mekong Bobtail",
Country: "Russia",
Origin: "Natural/Mutation",
Coat: "Short",
Pattern: "Colorpoint",
},
{
Breed: "Minskin",
Country: "United States",
Origin: "Crossbreed",
Coat: "Short/Hairless",
Pattern: "All",
},
{
Breed: "Munchkin",
Country: "United States",
Origin: "Mutation",
Coat: "",
Pattern: "",
},
{
Breed: "Nebelung",
Country: "United States",
Origin: "",
Coat: "Semi-long",
Pattern: "Solid",
},
{
Breed: "Napoleon",
Country: "",
Origin: "",
Coat: "Long/short",
Pattern: "Varied",
},
{
Breed: "Norwegian Forest cat",
Country: "Norway",
Origin: "Natural",
Coat: "Long",
Pattern: "All but colorpoint",
},
{
Breed: "Ocicat",
Country: "United States",
Origin: "Crossbreed",
Coat: "Short",
Pattern: "Spotted",
},
{
Breed: "Ojos Azules",
Country: "United States",
Origin: "",
Coat: "",
Pattern: "",
},
{
Breed: "Oregon Rex",
Country: "United States",
Origin: "Mutation",
Coat: "Rex",
Pattern: "",
},
{
Breed: "Oriental Bicolor",
Country: "",
Origin: "",
Coat: "",
Pattern: "Bicolor",
},
{
Breed: "Oriental Shorthair",
Country: "",
Origin: "",
Coat: "Short",
Pattern: "All but colorpoint",
},
{
Breed: "Oriental Longhair",
Country: "",
Origin: "",
Coat: "Semi-long",
Pattern: "",
},
{
Breed: "PerFoldæ(Experimental Breed - WCF)",
Country: "Europe",
Origin: "Crossbreed",
Coat: "Long",
Pattern: "All",
},
{
Breed: "Persian (Modern Persian Cat)",
Country: "Iran (Persia)",
Origin: "Crossbreed",
Coat: "Long",
Pattern: "All",
},
{
Breed: "Persian (Traditional Persian Cat)",
Country: "Greater Iran",
Origin: "Natural",
Coat: "Long",
Pattern: "All",
},
{
Breed: "Peterbald",
Country: "Russia",
Origin: "Crossbreed",
Coat: "Hairless",
Pattern: "All",
},
{
Breed: "Pixie-bob",
Country: "United States",
Origin: "Natural",
Coat: "Short",
Pattern: "Spotted",
},
{
Breed: "Raas",
Country: "Indonesia",
Origin: "Natural",
Coat: "Short",
Pattern: "",
},
{
Breed: "Ragamuffin",
Country: "United States",
Origin: "Crossbreed",
Coat: "Long",
Pattern: "All",
},
{
Breed: "Ragdoll",
Country: "United States",
Origin: "Crossbreed",
Coat: "Long",
Pattern: "Colorpoint/Mitted/Bicolor",
},
{
Breed: "Russian Blue",
Country: "Russia",
Origin: "Natural",
Coat: "Short",
Pattern: "Solid",
},
{
Breed: "Russian White, Black and Tabby",
Country: "Australia",
Origin: "Crossbreed",
Coat: "Short",
Pattern: "",
},
{
Breed: "Sam Sawet",
Country: "Thailand",
Origin: "Natural",
Coat: "Short",
Pattern: "Solid",
},
{
Breed: "Savannah",
Country: "United States",
Origin: "Hybrid",
Coat: "Short",
Pattern: "Spotted",
},
{
Breed: "Scottish Fold",
Country: "United Kingdom (Scotland)",
Origin: "Natural/Mutation",
Coat: "Short/Long",
Pattern: "All",
},
{
Breed: "Selkirk Rex",
Country: "United States",
Origin: "Mutation/Cross",
Coat: "Rex (Short/Long)",
Pattern: "All",
},
{
Breed: "Serengeti",
Country: "United States",
Origin: "Hybrid Crossbreed",
Coat: "Short",
Pattern: "Spotted",
},
{
Breed: "Serrade petit",
Country: "France",
Origin: "Natural",
Coat: "Short",
Pattern: "",
},
{
Breed: "Siamese",
Country: "Thailand",
Origin: "Natural",
Coat: "Short",
Pattern: "Colorpoint",
},
{
Breed: "Siberian",
Country: "Russia",
Origin: "Natural",
Coat: "Semi-long",
Pattern: "All",
},
{
Breed: "Singapura",
Country: "Singapore",
Origin: "Natural",
Coat: "Short",
Pattern: "Ticked",
},
{
Breed: "Snowshoe",
Country: "United States",
Origin: "Crossbreed",
Coat: "Short",
Pattern: "Colorpoint",
},
{
Breed: "Sokoke",
Country: "Kenya",
Origin: "Natural",
Coat: "Short",
Pattern: "Classic tabby with ticking",
},
{
Breed: "Somali",
Country: "Somalia",
Origin: "Mutation",
Coat: "Long",
Pattern: "Ticked",
},
{
Breed: "Sphynx",
Country: "Canada",
Origin: "Mutation",
Coat: "Hairless",
Pattern: "All",
},
{
Breed: "Suphalak",
Country: "Thailand",
Origin: "Natural",
Coat: "Short",
Pattern: "Solid",
},
{
Breed: "Thai",
Country: "Thailand",
Origin: "Natural",
Coat: "Short",
Pattern: "Colorpoint",
},
{
Breed: "Thai Lilac",
Country: "Thailand",
Origin: "Natural",
Coat: "Short",
Pattern: "Solid",
},
{
Breed: "Tonkinese",
Country: "Canada",
Origin: "Crossbreed",
Coat: "Short",
Pattern: "Colorpoint/Mink/Solid",
},
{
Breed: "Toyger",
Country: "United States",
Origin: "Crossbreed",
Coat: "Short",
Pattern: "Mackerel",
},
{
Breed: "Turkish Angora",
Country: "Turkey",
Origin: "Natural",
Coat: "Semi-long",
Pattern: "All but colorpoint",
},
{
Breed: "Ukrainian Levkoy",
Country: "Ukraine",
Origin: "",
Coat: "Hairless",
Pattern: "",
},
{
Breed: "York Chocolate",
Country: "United States (New York)",
Origin: "Natural",
Coat: "Long",
Pattern: "Solid",
},
}

View File

@ -2,61 +2,15 @@ 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{
var pcAbout templates.PageContext = templates.PageContext{
Title: "Welcome to the demo - About",
ActivePage: "about",
}
templates.About(pc, catFacts).Render(c, c.Writer)
func About(c *gin.Context) {
templates.About(pcAbout).Render(c, c.Writer)
}

View File

@ -0,0 +1,52 @@
package handlers
import (
"strconv"
"strings"
"templ-tests/app/data"
"templ-tests/app/templates"
"templ-tests/app/types"
"github.com/gin-gonic/gin"
)
var pcInteractive templates.PageContext = templates.PageContext{
Title: "Welcome to the demo",
ActivePage: "interactive",
}
func Interactive(c *gin.Context) {
templates.Interactive(pcInteractive, data.CatBreeds).Render(c, c.Writer)
}
func InteractiveSwapContent(c *gin.Context) {
contentIndexStr := c.Query("content")
contentIndex, err := strconv.Atoi(contentIndexStr)
if err != nil {
contentIndex = 0
}
templates.InteractiveSwapContent(pcInteractive, contentIndex).Render(c, c.Writer)
}
func FilterCatBreeds(c *gin.Context) {
breedQuery := strings.ToLower(c.Query("breed"))
countryQuery := c.Query("country")
var catBreeds []types.CatBreed = []types.CatBreed{}
for _, cb := range data.CatBreeds {
appendToList :=
(len(breedQuery) > 0 &&
strings.Contains(strings.ToLower(cb.Breed), breedQuery) ||
len(breedQuery) == 0) &&
((len(countryQuery) > 0 &&
cb.Country == countryQuery) ||
len(countryQuery) == 0)
if appendToList {
catBreeds = append(catBreeds, cb)
}
}
templates.RenderCatBreedsTable(catBreeds).Render(c, c.Writer)
}

View File

@ -22,6 +22,13 @@ func initRouter() *gin.Engine {
router.GET("/", handlers.Home)
router.GET("/about", handlers.About)
interactiveRouter := router.Group("/interactive")
{
interactiveRouter.GET("", handlers.Interactive)
interactiveRouter.GET("/swap-content", handlers.InteractiveSwapContent)
interactiveRouter.GET("/filter-cat-breeds", handlers.FilterCatBreeds)
}
router.Use(static.Serve("/static", static.LocalFile(STATIC_PATH, false)))
return router

View File

@ -1,33 +1,7 @@
package templates
import (
"templ-tests/app/types"
)
templ About(pc PageContext, catFacts []types.CatFact) {
templ About(pc PageContext) {
@baseLayout(pc) {
<table class="table">
<thead>
<tr>
<th>Breed</th>
<th>Country</th>
<th>Origin</th>
<th>Coat</th>
<th>Pattern</th>
</tr>
</thead>
<tbody>
for _, fact := range catFacts {
<tr>
<td>{ fact.Breed }</td>
<td>{ fact.Country }</td>
<td>{ fact.Origin }</td>
<td>{ fact.Coat }</td>
<td>{ fact.Pattern }</td>
</tr>
}
</tbody>
</table>
<p>Bacon ipsum dolor amet cow capicola pancetta picanha biltong brisket filet mignon turducken beef ribs burgdoggen landjaeger meatball venison shank. Capicola ham pork chop, biltong kielbasa pancetta short loin jowl cupim pig jerky drumstick turducken burgdoggen beef. Spare ribs flank ribeye cow doner, shank chuck bacon ham hock porchetta kielbasa tri-tip. Ham t-bone chislic, capicola andouille ham hock frankfurter tri-tip sausage kevin landjaeger shank ribeye. Swine tri-tip spare ribs, rump flank bresaola kevin tail. Meatball tail picanha cow, frankfurter ribeye sirloin pork belly short loin pig. Filet mignon spare ribs pastrami, tri-tip ball tip tongue fatback pork chop.</p>
<p>Cupim biltong salami meatball ball tip buffalo, shoulder tenderloin beef ribs porchetta tail boudin chislic. Pastrami short ribs bresaola spare ribs, ham landjaeger brisket flank buffalo sirloin meatloaf tail chislic kielbasa. Leberkas t-bone hamburger pastrami, tri-tip tenderloin spare ribs alcatra filet mignon swine. Pork chop meatball buffalo alcatra cow beef, spare ribs pork loin pork ball tip corned beef sirloin pork belly fatback ham hock. Meatball ham hock filet mignon frankfurter, burgdoggen swine shankle pork belly chuck buffalo andouille corned beef pastrami turkey. Andouille short loin capicola tail pork belly biltong.</p>
<p>Frankfurter t-bone hamburger meatball tongue capicola. Sausage beef ribs pig, landjaeger salami kielbasa shank cow strip steak doner brisket drumstick sirloin. Ground round ham pork belly pig tri-tip, pastrami ham hock. Bacon shankle brisket rump pork loin drumstick. Chicken shankle picanha corned beef sirloin. Venison kevin jerky ham kielbasa. Prosciutto pork chop brisket pork belly.</p>

View File

@ -10,11 +10,7 @@ import "context"
import "io"
import "bytes"
import (
"templ-tests/app/types"
)
func About(pc PageContext, catFacts []types.CatFact) templ.Component {
func About(pc PageContext) templ.Component {
return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
if !templ_7745c5c3_IsBuffer {
@ -33,132 +29,57 @@ func About(pc PageContext, catFacts []types.CatFact) templ.Component {
templ_7745c5c3_Buffer = templ.GetBuffer()
defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<table class=\"table\"><thead><tr><th>")
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<p>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Var3 := `Breed`
templ_7745c5c3_Var3 := `Bacon ipsum dolor amet cow capicola pancetta picanha biltong brisket filet mignon turducken beef ribs burgdoggen landjaeger meatball venison shank. Capicola ham pork chop, biltong kielbasa pancetta short loin jowl cupim pig jerky drumstick turducken burgdoggen beef. Spare ribs flank ribeye cow doner, shank chuck bacon ham hock porchetta kielbasa tri-tip. Ham t-bone chislic, capicola andouille ham hock frankfurter tri-tip sausage kevin landjaeger shank ribeye. Swine tri-tip spare ribs, rump flank bresaola kevin tail. Meatball tail picanha cow, frankfurter ribeye sirloin pork belly short loin pig. Filet mignon spare ribs pastrami, tri-tip ball tip tongue fatback pork chop.`
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var3)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</th><th>")
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</p><p>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Var4 := `Country`
templ_7745c5c3_Var4 := `Cupim biltong salami meatball ball tip buffalo, shoulder tenderloin beef ribs porchetta tail boudin chislic. Pastrami short ribs bresaola spare ribs, ham landjaeger brisket flank buffalo sirloin meatloaf tail chislic kielbasa. Leberkas t-bone hamburger pastrami, tri-tip tenderloin spare ribs alcatra filet mignon swine. Pork chop meatball buffalo alcatra cow beef, spare ribs pork loin pork ball tip corned beef sirloin pork belly fatback ham hock. Meatball ham hock filet mignon frankfurter, burgdoggen swine shankle pork belly chuck buffalo andouille corned beef pastrami turkey. Andouille short loin capicola tail pork belly biltong.`
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var4)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</th><th>")
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</p><p>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Var5 := `Origin`
templ_7745c5c3_Var5 := `Frankfurter t-bone hamburger meatball tongue capicola. Sausage beef ribs pig, landjaeger salami kielbasa shank cow strip steak doner brisket drumstick sirloin. Ground round ham pork belly pig tri-tip, pastrami ham hock. Bacon shankle brisket rump pork loin drumstick. Chicken shankle picanha corned beef sirloin. Venison kevin jerky ham kielbasa. Prosciutto pork chop brisket pork belly.`
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var5)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</th><th>")
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</p><p>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Var6 := `Coat`
templ_7745c5c3_Var6 := `Landjaeger tenderloin t-bone turkey buffalo, turducken beef ribs ham hock chuck frankfurter strip steak. Chuck frankfurter jowl jerky tri-tip bacon cow ribeye buffalo capicola bresaola drumstick beef ribs pork belly. Pig brisket tail prosciutto cupim andouille. Venison ground round kielbasa prosciutto jerky spare ribs. Meatball sirloin jerky, turducken tri-tip kevin brisket pork chop sausage rump. Ball tip pork loin frankfurter pig, capicola prosciutto tail bacon short ribs. Chislic porchetta meatloaf, picanha spare ribs kielbasa beef kevin capicola pork loin.`
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var6)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</th><th>")
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</p><p>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Var7 := `Pattern`
templ_7745c5c3_Var7 := `Tenderloin corned beef prosciutto fatback salami porchetta capicola meatball chuck jowl pork loin shoulder short ribs. Ham hock doner biltong, salami cow jerky bresaola drumstick short loin shankle chuck andouille ground round buffalo. Shankle pork belly landjaeger, corned beef hamburger sausage sirloin swine filet mignon short loin kevin. Jowl picanha pork chop meatball salami corned beef kielbasa. Ribeye leberkas bacon pork loin pig, flank porchetta andouille sausage. T-bone alcatra rump pancetta landjaeger ground round cupim prosciutto shankle ham burgdoggen flank.`
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var7)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</th></tr></thead> <tbody>")
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</p><p>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
for _, fact := range catFacts {
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<tr><td>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var8 string
templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(fact.Breed)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `app/templates/about.templ`, Line: 21, Col: 22}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</td><td>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var9 string
templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(fact.Country)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `app/templates/about.templ`, Line: 22, Col: 24}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var9))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</td><td>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var10 string
templ_7745c5c3_Var10, templ_7745c5c3_Err = templ.JoinStringErrs(fact.Origin)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `app/templates/about.templ`, Line: 23, Col: 23}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var10))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</td><td>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var11 string
templ_7745c5c3_Var11, templ_7745c5c3_Err = templ.JoinStringErrs(fact.Coat)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `app/templates/about.templ`, Line: 24, Col: 21}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var11))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</td><td>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var12 string
templ_7745c5c3_Var12, templ_7745c5c3_Err = templ.JoinStringErrs(fact.Pattern)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `app/templates/about.templ`, Line: 25, Col: 24}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var12))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</td></tr>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</tbody></table><p>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Var13 := `Bacon ipsum dolor amet cow capicola pancetta picanha biltong brisket filet mignon turducken beef ribs burgdoggen landjaeger meatball venison shank. Capicola ham pork chop, biltong kielbasa pancetta short loin jowl cupim pig jerky drumstick turducken burgdoggen beef. Spare ribs flank ribeye cow doner, shank chuck bacon ham hock porchetta kielbasa tri-tip. Ham t-bone chislic, capicola andouille ham hock frankfurter tri-tip sausage kevin landjaeger shank ribeye. Swine tri-tip spare ribs, rump flank bresaola kevin tail. Meatball tail picanha cow, frankfurter ribeye sirloin pork belly short loin pig. Filet mignon spare ribs pastrami, tri-tip ball tip tongue fatback pork chop.`
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var13)
templ_7745c5c3_Var8 := `Jerky turkey pork, burgdoggen shank filet mignon corned beef ham chislic flank prosciutto kielbasa frankfurter. Turkey bresaola salami spare ribs rump, prosciutto short loin strip steak andouille filet mignon tenderloin kielbasa. Flank jowl fatback rump spare ribs. Jowl meatball leberkas rump. Doner buffalo bacon beef pig tail porchetta biltong boudin alcatra pork belly.`
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var8)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@ -166,8 +87,8 @@ func About(pc PageContext, catFacts []types.CatFact) templ.Component {
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Var14 := `Cupim biltong salami meatball ball tip buffalo, shoulder tenderloin beef ribs porchetta tail boudin chislic. Pastrami short ribs bresaola spare ribs, ham landjaeger brisket flank buffalo sirloin meatloaf tail chislic kielbasa. Leberkas t-bone hamburger pastrami, tri-tip tenderloin spare ribs alcatra filet mignon swine. Pork chop meatball buffalo alcatra cow beef, spare ribs pork loin pork ball tip corned beef sirloin pork belly fatback ham hock. Meatball ham hock filet mignon frankfurter, burgdoggen swine shankle pork belly chuck buffalo andouille corned beef pastrami turkey. Andouille short loin capicola tail pork belly biltong.`
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var14)
templ_7745c5c3_Var9 := `Porchetta biltong tri-tip kielbasa short ribs ham ground round t-bone venison. Prosciutto hamburger biltong, meatball tongue drumstick ham hock beef ribs. Porchetta jowl boudin, spare ribs tri-tip tenderloin meatloaf shankle landjaeger. Filet mignon meatball ribeye, hamburger kevin turkey cow.`
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var9)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@ -175,8 +96,8 @@ func About(pc PageContext, catFacts []types.CatFact) templ.Component {
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Var15 := `Frankfurter t-bone hamburger meatball tongue capicola. Sausage beef ribs pig, landjaeger salami kielbasa shank cow strip steak doner brisket drumstick sirloin. Ground round ham pork belly pig tri-tip, pastrami ham hock. Bacon shankle brisket rump pork loin drumstick. Chicken shankle picanha corned beef sirloin. Venison kevin jerky ham kielbasa. Prosciutto pork chop brisket pork belly.`
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var15)
templ_7745c5c3_Var10 := `Kevin andouille sausage pancetta chuck porchetta alcatra meatloaf. Cupim picanha short loin prosciutto leberkas pork, doner ham hock buffalo shankle tongue. Brisket hamburger tail beef chicken shankle capicola meatloaf pork loin porchetta t-bone. Shankle ham hock jowl ham. Sirloin sausage jerky t-bone.`
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var10)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@ -184,8 +105,8 @@ func About(pc PageContext, catFacts []types.CatFact) templ.Component {
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Var16 := `Landjaeger tenderloin t-bone turkey buffalo, turducken beef ribs ham hock chuck frankfurter strip steak. Chuck frankfurter jowl jerky tri-tip bacon cow ribeye buffalo capicola bresaola drumstick beef ribs pork belly. Pig brisket tail prosciutto cupim andouille. Venison ground round kielbasa prosciutto jerky spare ribs. Meatball sirloin jerky, turducken tri-tip kevin brisket pork chop sausage rump. Ball tip pork loin frankfurter pig, capicola prosciutto tail bacon short ribs. Chislic porchetta meatloaf, picanha spare ribs kielbasa beef kevin capicola pork loin.`
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var16)
templ_7745c5c3_Var11 := `Jowl bresaola alcatra pastrami pork belly rump short loin shoulder swine jerky flank sirloin andouille. Spare ribs sausage fatback venison flank pancetta. Pork chop ground round sirloin pork belly turkey swine buffalo tri-tip frankfurter landjaeger tongue turducken ball tip. Sirloin jerky meatloaf boudin.`
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var11)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@ -193,53 +114,8 @@ func About(pc PageContext, catFacts []types.CatFact) templ.Component {
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Var17 := `Tenderloin corned beef prosciutto fatback salami porchetta capicola meatball chuck jowl pork loin shoulder short ribs. Ham hock doner biltong, salami cow jerky bresaola drumstick short loin shankle chuck andouille ground round buffalo. Shankle pork belly landjaeger, corned beef hamburger sausage sirloin swine filet mignon short loin kevin. Jowl picanha pork chop meatball salami corned beef kielbasa. Ribeye leberkas bacon pork loin pig, flank porchetta andouille sausage. T-bone alcatra rump pancetta landjaeger ground round cupim prosciutto shankle ham burgdoggen flank.`
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var17)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</p><p>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Var18 := `Jerky turkey pork, burgdoggen shank filet mignon corned beef ham chislic flank prosciutto kielbasa frankfurter. Turkey bresaola salami spare ribs rump, prosciutto short loin strip steak andouille filet mignon tenderloin kielbasa. Flank jowl fatback rump spare ribs. Jowl meatball leberkas rump. Doner buffalo bacon beef pig tail porchetta biltong boudin alcatra pork belly.`
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var18)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</p><p>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Var19 := `Porchetta biltong tri-tip kielbasa short ribs ham ground round t-bone venison. Prosciutto hamburger biltong, meatball tongue drumstick ham hock beef ribs. Porchetta jowl boudin, spare ribs tri-tip tenderloin meatloaf shankle landjaeger. Filet mignon meatball ribeye, hamburger kevin turkey cow.`
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var19)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</p><p>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Var20 := `Kevin andouille sausage pancetta chuck porchetta alcatra meatloaf. Cupim picanha short loin prosciutto leberkas pork, doner ham hock buffalo shankle tongue. Brisket hamburger tail beef chicken shankle capicola meatloaf pork loin porchetta t-bone. Shankle ham hock jowl ham. Sirloin sausage jerky t-bone.`
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var20)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</p><p>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Var21 := `Jowl bresaola alcatra pastrami pork belly rump short loin shoulder swine jerky flank sirloin andouille. Spare ribs sausage fatback venison flank pancetta. Pork chop ground round sirloin pork belly turkey swine buffalo tri-tip frankfurter landjaeger tongue turducken ball tip. Sirloin jerky meatloaf boudin.`
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var21)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</p><p>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Var22 := `Biltong turducken swine venison bacon, hamburger corned beef pork chop ham hock. Strip steak t-bone ham hock shoulder turducken leberkas chislic sirloin biltong pork belly kielbasa burgdoggen buffalo. T-bone frankfurter jerky, shoulder andouille short ribs rump meatloaf kevin swine tongue. Sirloin corned beef sausage, filet mignon picanha short loin bresaola alcatra boudin strip steak turducken.`
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var22)
templ_7745c5c3_Var12 := `Biltong turducken swine venison bacon, hamburger corned beef pork chop ham hock. Strip steak t-bone ham hock shoulder turducken leberkas chislic sirloin biltong pork belly kielbasa burgdoggen buffalo. T-bone frankfurter jerky, shoulder andouille short ribs rump meatloaf kevin swine tongue. Sirloin corned beef sausage, filet mignon picanha short loin bresaola alcatra boudin strip steak turducken.`
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var12)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}

View File

@ -0,0 +1,163 @@
package templates
import (
"templ-tests/app/types"
"templ-tests/app/data"
"slices"
"sort"
)
templ interactiveButtons() {
<h3 class="mb-3">
Interactive buttons
</h3>
<button
type="button"
class="btn btn-primary mb-3"
hx-get="/interactive/swap-content?content=1"
hx-target="#swap-content-target"
>
Swap to content 1
</button>
<button
type="button"
class="btn btn-primary mb-3"
hx-get="/interactive/swap-content?content=2"
hx-target="#swap-content-target"
>
Swap to content 2
</button>
<button
type="button"
class="btn btn-primary mb-3"
hx-get="/interactive/swap-content?content=3"
hx-target="#swap-content-target"
>
Swap to content 3
</button>
<p id="swap-content-target">
Bacon ipsum dolor amet cow capicola pancetta picanha biltong brisket filet mignon turducken beef ribs burgdoggen landjaeger meatball venison shank. Capicola ham pork chop, biltong kielbasa pancetta short loin jowl cupim pig jerky drumstick turducken burgdoggen beef. Spare ribs flank ribeye cow doner, shank chuck bacon ham hock porchetta kielbasa tri-tip. Ham t-bone chislic, capicola andouille ham hock frankfurter tri-tip sausage kevin landjaeger shank ribeye. Swine tri-tip spare ribs, rump flank bresaola kevin tail. Meatball tail picanha cow, frankfurter ribeye sirloin pork belly short loin pig. Filet mignon spare ribs pastrami, tri-tip ball tip tongue fatback pork chop.
</p>
}
func getCatCountriesOptions() []string {
var res []string = []string{}
for _, cb := range data.CatBreeds {
if len(cb.Country) > 0 && !slices.Contains(res, cb.Country) {
res = append(res, cb.Country)
}
}
sort.Strings(res)
return res
}
templ catBreedsSection(catBreeds []types.CatBreed) {
<h3 class="mt-5 mb-3">
Cat breeds
</h3>
<div class="card mb-2">
<div class="card-body">
<form
class="row g-3 align-items-center"
>
<div class="col-auto">
<label class="form-label">Breed:</label>
</div>
<div class="col-auto">
<input
type="text"
name="breed"
class="form-control"
hx-get="/interactive/filter-cat-breeds"
hx-target="#cat-breeds-table"
hx-trigger="keyup"
hx-include="select[name='country']"
/>
</div>
<div class="col-auto">
<label class="form-label">Country:</label>
</div>
<div class="col-auto">
<select
name="country"
class="form-select"
hx-get="/interactive/filter-cat-breeds"
hx-target="#cat-breeds-table"
hx-trigger="change"
hx-include="input[name='breed']"
>
<option value="">
- All -
</option>
for _, opt := range getCatCountriesOptions() {
<option value={ opt }>
{ opt }
</option>
}
</select>
</div>
</form>
</div>
</div>
@catBreedsTable(catBreeds)
}
templ catBreedsTable(catBreeds []types.CatBreed) {
<table class="table" id="cat-breeds-table">
<thead>
<tr>
<th>Breed</th>
<th>Country</th>
<th>Origin</th>
<th>Coat</th>
<th>Pattern</th>
</tr>
</thead>
<tbody>
for _, breed := range catBreeds {
<tr>
<td>{ breed.Breed }</td>
<td>{ breed.Country }</td>
<td>{ breed.Origin }</td>
<td>{ breed.Coat }</td>
<td>{ breed.Pattern }</td>
</tr>
}
</tbody>
</table>
}
templ Interactive(pc PageContext, catBreeds []types.CatBreed) {
@baseLayout(pc) {
@interactiveButtons()
@catBreedsSection(catBreeds)
}
}
templ InteractiveSwapContent(pc PageContext, contentIndex int) {
switch contentIndex {
case 1:
<p>
Some new content 1...
</p>
case 2:
<p>
Some new content 2...
</p>
case 3:
<p>
Some new content 3...
</p>
default:
<p>
Some new content with unknown index...
</p>
}
}
templ RenderCatBreedsTable(catBreeds []types.CatBreed) {
@catBreedsTable(catBreeds)
}

View File

@ -0,0 +1,489 @@
// Code generated by templ - DO NOT EDIT.
// templ: version: v0.2.513
package templates
//lint:file-ignore SA4006 This context is only used if a nested component is present.
import "github.com/a-h/templ"
import "context"
import "io"
import "bytes"
import (
"slices"
"sort"
"templ-tests/app/data"
"templ-tests/app/types"
)
func interactiveButtons() templ.Component {
return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
if !templ_7745c5c3_IsBuffer {
templ_7745c5c3_Buffer = templ.GetBuffer()
defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
}
ctx = templ.InitializeContext(ctx)
templ_7745c5c3_Var1 := templ.GetChildren(ctx)
if templ_7745c5c3_Var1 == nil {
templ_7745c5c3_Var1 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<h3 class=\"mb-3\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Var2 := `Interactive buttons`
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var2)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</h3><button type=\"button\" class=\"btn btn-primary mb-3\" hx-get=\"/interactive/swap-content?content=1\" hx-target=\"#swap-content-target\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Var3 := `Swap to content 1`
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var3)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</button> <button type=\"button\" class=\"btn btn-primary mb-3\" hx-get=\"/interactive/swap-content?content=2\" hx-target=\"#swap-content-target\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Var4 := `Swap to content 2`
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var4)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</button> <button type=\"button\" class=\"btn btn-primary mb-3\" hx-get=\"/interactive/swap-content?content=3\" hx-target=\"#swap-content-target\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Var5 := `Swap to content 3`
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var5)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</button><p id=\"swap-content-target\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Var6 := `Bacon ipsum dolor amet cow capicola pancetta picanha biltong brisket filet mignon turducken beef ribs burgdoggen landjaeger meatball venison shank. Capicola ham pork chop, biltong kielbasa pancetta short loin jowl cupim pig jerky drumstick turducken burgdoggen beef. Spare ribs flank ribeye cow doner, shank chuck bacon ham hock porchetta kielbasa tri-tip. Ham t-bone chislic, capicola andouille ham hock frankfurter tri-tip sausage kevin landjaeger shank ribeye. Swine tri-tip spare ribs, rump flank bresaola kevin tail. Meatball tail picanha cow, frankfurter ribeye sirloin pork belly short loin pig. Filet mignon spare ribs pastrami, tri-tip ball tip tongue fatback pork chop.`
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var6)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</p>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
if !templ_7745c5c3_IsBuffer {
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W)
}
return templ_7745c5c3_Err
})
}
func getCatCountriesOptions() []string {
var res []string = []string{}
for _, cb := range data.CatBreeds {
if len(cb.Country) > 0 && !slices.Contains(res, cb.Country) {
res = append(res, cb.Country)
}
}
sort.Strings(res)
return res
}
func catBreedsSection(catBreeds []types.CatBreed) templ.Component {
return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
if !templ_7745c5c3_IsBuffer {
templ_7745c5c3_Buffer = templ.GetBuffer()
defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
}
ctx = templ.InitializeContext(ctx)
templ_7745c5c3_Var7 := templ.GetChildren(ctx)
if templ_7745c5c3_Var7 == nil {
templ_7745c5c3_Var7 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<h3 class=\"mt-5 mb-3\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Var8 := `Cat breeds`
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var8)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</h3><div class=\"card mb-2\"><div class=\"card-body\"><form class=\"row g-3 align-items-center\"><div class=\"col-auto\"><label class=\"form-label\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Var9 := `Breed:`
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var9)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</label></div><div class=\"col-auto\"><input type=\"text\" name=\"breed\" class=\"form-control\" hx-get=\"/interactive/filter-cat-breeds\" hx-target=\"#cat-breeds-table\" hx-trigger=\"keyup\" hx-include=\"select[name=&#39;country&#39;]\"></div><div class=\"col-auto\"><label class=\"form-label\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Var10 := `Country:`
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var10)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</label></div><div class=\"col-auto\"><select name=\"country\" class=\"form-select\" hx-get=\"/interactive/filter-cat-breeds\" hx-target=\"#cat-breeds-table\" hx-trigger=\"change\" hx-include=\"input[name=&#39;breed&#39;]\"><option value=\"\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Var11 := `- All -`
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var11)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</option> ")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
for _, opt := range getCatCountriesOptions() {
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<option value=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(opt))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var12 string
templ_7745c5c3_Var12, templ_7745c5c3_Err = templ.JoinStringErrs(opt)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `app/templates/interactive.templ`, Line: 96, Col: 13}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var12))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</option>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</select></div></form></div></div>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = catBreedsTable(catBreeds).Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
if !templ_7745c5c3_IsBuffer {
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W)
}
return templ_7745c5c3_Err
})
}
func catBreedsTable(catBreeds []types.CatBreed) templ.Component {
return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
if !templ_7745c5c3_IsBuffer {
templ_7745c5c3_Buffer = templ.GetBuffer()
defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
}
ctx = templ.InitializeContext(ctx)
templ_7745c5c3_Var13 := templ.GetChildren(ctx)
if templ_7745c5c3_Var13 == nil {
templ_7745c5c3_Var13 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<table class=\"table\" id=\"cat-breeds-table\"><thead><tr><th>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Var14 := `Breed`
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var14)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</th><th>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Var15 := `Country`
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var15)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</th><th>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Var16 := `Origin`
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var16)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</th><th>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Var17 := `Coat`
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var17)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</th><th>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Var18 := `Pattern`
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var18)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</th></tr></thead> <tbody>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
for _, breed := range catBreeds {
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<tr><td>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var19 string
templ_7745c5c3_Var19, templ_7745c5c3_Err = templ.JoinStringErrs(breed.Breed)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `app/templates/interactive.templ`, Line: 121, Col: 22}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var19))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</td><td>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var20 string
templ_7745c5c3_Var20, templ_7745c5c3_Err = templ.JoinStringErrs(breed.Country)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `app/templates/interactive.templ`, Line: 122, Col: 24}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var20))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</td><td>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var21 string
templ_7745c5c3_Var21, templ_7745c5c3_Err = templ.JoinStringErrs(breed.Origin)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `app/templates/interactive.templ`, Line: 123, Col: 23}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var21))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</td><td>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var22 string
templ_7745c5c3_Var22, templ_7745c5c3_Err = templ.JoinStringErrs(breed.Coat)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `app/templates/interactive.templ`, Line: 124, Col: 21}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var22))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</td><td>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var23 string
templ_7745c5c3_Var23, templ_7745c5c3_Err = templ.JoinStringErrs(breed.Pattern)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `app/templates/interactive.templ`, Line: 125, Col: 24}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var23))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</td></tr>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</tbody></table>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
if !templ_7745c5c3_IsBuffer {
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W)
}
return templ_7745c5c3_Err
})
}
func Interactive(pc PageContext, catBreeds []types.CatBreed) templ.Component {
return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
if !templ_7745c5c3_IsBuffer {
templ_7745c5c3_Buffer = templ.GetBuffer()
defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
}
ctx = templ.InitializeContext(ctx)
templ_7745c5c3_Var24 := templ.GetChildren(ctx)
if templ_7745c5c3_Var24 == nil {
templ_7745c5c3_Var24 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
templ_7745c5c3_Var25 := templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
if !templ_7745c5c3_IsBuffer {
templ_7745c5c3_Buffer = templ.GetBuffer()
defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
}
templ_7745c5c3_Err = interactiveButtons().Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(" ")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = catBreedsSection(catBreeds).Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
if !templ_7745c5c3_IsBuffer {
_, templ_7745c5c3_Err = io.Copy(templ_7745c5c3_W, templ_7745c5c3_Buffer)
}
return templ_7745c5c3_Err
})
templ_7745c5c3_Err = baseLayout(pc).Render(templ.WithChildren(ctx, templ_7745c5c3_Var25), templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
if !templ_7745c5c3_IsBuffer {
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W)
}
return templ_7745c5c3_Err
})
}
func InteractiveSwapContent(pc PageContext, contentIndex int) templ.Component {
return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
if !templ_7745c5c3_IsBuffer {
templ_7745c5c3_Buffer = templ.GetBuffer()
defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
}
ctx = templ.InitializeContext(ctx)
templ_7745c5c3_Var26 := templ.GetChildren(ctx)
if templ_7745c5c3_Var26 == nil {
templ_7745c5c3_Var26 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
switch contentIndex {
case 1:
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<p>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Var27 := `Some new content 1...`
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var27)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</p>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
case 2:
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<p>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Var28 := `Some new content 2...`
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var28)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</p>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
case 3:
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<p>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Var29 := `Some new content 3...`
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var29)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</p>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
default:
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<p>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Var30 := `Some new content with unknown index...`
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var30)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</p>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
if !templ_7745c5c3_IsBuffer {
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W)
}
return templ_7745c5c3_Err
})
}
func RenderCatBreedsTable(catBreeds []types.CatBreed) templ.Component {
return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
if !templ_7745c5c3_IsBuffer {
templ_7745c5c3_Buffer = templ.GetBuffer()
defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
}
ctx = templ.InitializeContext(ctx)
templ_7745c5c3_Var31 := templ.GetChildren(ctx)
if templ_7745c5c3_Var31 == nil {
templ_7745c5c3_Var31 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
templ_7745c5c3_Err = catBreedsTable(catBreeds).Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
if !templ_7745c5c3_IsBuffer {
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W)
}
return templ_7745c5c3_Err
})
}

View File

@ -8,6 +8,7 @@ templ baseLayout(pc PageContext) {
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous"/>
<link rel="stylesheet" href="/static/styles.css"/>
<script src="/static/js/htmx.min.js"></script>
<title>{ pc.Title }</title>
</head>
<body>
@ -17,15 +18,20 @@ templ baseLayout(pc PageContext) {
</h1>
<ul class="nav nav-pills mb-5">
<li class="nav-item">
<a class={ "nav-link", templ.KV("active", pc.ActivePage == "home") } aria-current="page" href="/">
<a class={ "nav-link", templ.KV("active", pc.ActivePage == "home") } href="/">
Home
</a>
</li>
<li class="nav-item">
<a class={ "nav-link", templ.KV("active", pc.ActivePage == "about") } aria-current="page" href="/about">
<a class={ "nav-link", templ.KV("active", pc.ActivePage == "about") } href="/about">
About
</a>
</li>
<li class="nav-item">
<a class={ "nav-link", templ.KV("active", pc.ActivePage == "interactive") } href="/interactive">
Interactive
</a>
</li>
</ul>
if pc.User != nil {
<p class="alert alert-warning">

View File

@ -23,16 +23,25 @@ func baseLayout(pc PageContext) templ.Component {
templ_7745c5c3_Var1 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<!doctype html><html lang=\"en\"><head><meta charset=\"UTF-8\"><meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"><link rel=\"stylesheet\" href=\"https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css\" integrity=\"sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN\" crossorigin=\"anonymous\"><link rel=\"stylesheet\" href=\"/static/styles.css\"><title>")
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<!doctype html><html lang=\"en\"><head><meta charset=\"UTF-8\"><meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"><link rel=\"stylesheet\" href=\"https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css\" integrity=\"sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN\" crossorigin=\"anonymous\"><link rel=\"stylesheet\" href=\"/static/styles.css\"><script src=\"/static/js/htmx.min.js\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var2 string
templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(pc.Title)
templ_7745c5c3_Var2 := ``
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var2)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `app/templates/layout.templ`, Line: 10, Col: 20}
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2))
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</script><title>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var3 string
templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(pc.Title)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `app/templates/layout.templ`, Line: 11, Col: 20}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@ -40,8 +49,8 @@ func baseLayout(pc PageContext) templ.Component {
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Var3 := `Go + templ demo`
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var3)
templ_7745c5c3_Var4 := `Go + templ demo`
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var4)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@ -49,8 +58,8 @@ func baseLayout(pc PageContext) templ.Component {
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var4 = []any{"nav-link", templ.KV("active", pc.ActivePage == "home")}
templ_7745c5c3_Err = templ.RenderCSSItems(ctx, templ_7745c5c3_Buffer, templ_7745c5c3_Var4...)
var templ_7745c5c3_Var5 = []any{"nav-link", templ.KV("active", pc.ActivePage == "home")}
templ_7745c5c3_Err = templ.RenderCSSItems(ctx, templ_7745c5c3_Buffer, templ_7745c5c3_Var5...)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@ -58,16 +67,16 @@ func baseLayout(pc PageContext) templ.Component {
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ.CSSClasses(templ_7745c5c3_Var4).String()))
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ.CSSClasses(templ_7745c5c3_Var5).String()))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\" aria-current=\"page\" href=\"/\">")
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\" href=\"/\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Var5 := `Home`
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var5)
templ_7745c5c3_Var6 := `Home`
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var6)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@ -75,8 +84,8 @@ func baseLayout(pc PageContext) templ.Component {
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var6 = []any{"nav-link", templ.KV("active", pc.ActivePage == "about")}
templ_7745c5c3_Err = templ.RenderCSSItems(ctx, templ_7745c5c3_Buffer, templ_7745c5c3_Var6...)
var templ_7745c5c3_Var7 = []any{"nav-link", templ.KV("active", pc.ActivePage == "about")}
templ_7745c5c3_Err = templ.RenderCSSItems(ctx, templ_7745c5c3_Buffer, templ_7745c5c3_Var7...)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@ -84,16 +93,42 @@ func baseLayout(pc PageContext) templ.Component {
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ.CSSClasses(templ_7745c5c3_Var6).String()))
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ.CSSClasses(templ_7745c5c3_Var7).String()))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\" aria-current=\"page\" href=\"/about\">")
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\" href=\"/about\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Var7 := `About`
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var7)
templ_7745c5c3_Var8 := `About`
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var8)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</a></li><li class=\"nav-item\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var9 = []any{"nav-link", templ.KV("active", pc.ActivePage == "interactive")}
templ_7745c5c3_Err = templ.RenderCSSItems(ctx, templ_7745c5c3_Buffer, templ_7745c5c3_Var9...)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<a class=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ.CSSClasses(templ_7745c5c3_Var9).String()))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\" href=\"/interactive\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Var10 := `Interactive`
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var10)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@ -106,17 +141,17 @@ func baseLayout(pc PageContext) templ.Component {
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Var8 := `Hello, `
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var8)
templ_7745c5c3_Var11 := `Hello, `
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var11)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var9 string
templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(pc.User.FirstName)
var templ_7745c5c3_Var12 string
templ_7745c5c3_Var12, templ_7745c5c3_Err = templ.JoinStringErrs(pc.User.FirstName)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `app/templates/layout.templ`, Line: 31, Col: 32}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `app/templates/layout.templ`, Line: 37, Col: 32}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var9))
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var12))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}

View File

@ -1,6 +1,6 @@
package types
type CatFact struct {
type CatBreed struct {
Breed string
Country string
Origin string

1
static/js/htmx.min.js vendored Normal file

File diff suppressed because one or more lines are too long