| |
|
|
| |
| package main |
|
|
| |
|
|
| import "github.com/a-h/templ" |
| import templruntime "github.com/a-h/templ/runtime" |
|
|
| func Search(q string, results []Recipe, tags map[string]int) templ.Component { |
| return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { |
| templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context |
| if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { |
| return templ_7745c5c3_CtxErr |
| } |
| templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) |
| if !templ_7745c5c3_IsBuffer { |
| defer func() { |
| templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) |
| if templ_7745c5c3_Err == nil { |
| templ_7745c5c3_Err = templ_7745c5c3_BufErr |
| } |
| }() |
| } |
| 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 = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "<!doctype html><html lang=\"he\"><head><meta charset=\"utf-8\"><title>Search - Hebrew Recipes</title><link rel=\"stylesheet\" href=\"/static/style.css\"></head><body><header><a href=\"/\">Back</a><h1>Search</h1><form action=\"/search\" method=\"get\" class=\"search-form\"><input name=\"q\" value=\"") |
| if templ_7745c5c3_Err != nil { |
| return templ_7745c5c3_Err |
| } |
| var templ_7745c5c3_Var2 string |
| templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(q) |
| if templ_7745c5c3_Err != nil { |
| return templ.Error{Err: templ_7745c5c3_Err, FileName: `search.templ`, Line: 16, Col: 29} |
| } |
| _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2)) |
| if templ_7745c5c3_Err != nil { |
| return templ_7745c5c3_Err |
| } |
| templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, "\" placeholder=\"Search recipes...\"> <button type=\"submit\">Search</button></form></header><main><section id=\"results\"><h2>Results for '") |
| if templ_7745c5c3_Err != nil { |
| return templ_7745c5c3_Err |
| } |
| var templ_7745c5c3_Var3 string |
| templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(q) |
| if templ_7745c5c3_Err != nil { |
| return templ.Error{Err: templ_7745c5c3_Err, FileName: `search.templ`, Line: 22, Col: 24} |
| } |
| _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3)) |
| if templ_7745c5c3_Err != nil { |
| return templ_7745c5c3_Err |
| } |
| templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 3, "'</h2>") |
| if templ_7745c5c3_Err != nil { |
| return templ_7745c5c3_Err |
| } |
| templ_7745c5c3_Err = ListFragment(results, tags).Render(ctx, templ_7745c5c3_Buffer) |
| if templ_7745c5c3_Err != nil { |
| return templ_7745c5c3_Err |
| } |
| templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 4, "</section></main></body></html>") |
| if templ_7745c5c3_Err != nil { |
| return templ_7745c5c3_Err |
| } |
| return nil |
| }) |
| } |
|
|
| var _ = templruntime.GeneratedTemplate |
|
|