// Code generated by templ - DO NOT EDIT. // templ: version: v0.2.778 package tpl //lint:file-ignore SA4006 This context is only used if a nested component is present. import "github.com/a-h/templ" import templruntime "github.com/a-h/templ/runtime" import ( "fmt" "sh.org.ru/pkg/config" "sh.org.ru/pkg/middleware" "sh.org.ru/pkg/model" "strconv" ) func List(quotes []model.Quote, page, count 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) host := ctx.Value(middleware.ContextKey("config")).(*config.Config).Host templ_7745c5c3_Var2 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context 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) for _, q := range quotes { templ_7745c5c3_Err = Quote(&q).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 } var templ_7745c5c3_Var8 string templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(strconv.Itoa(count)) if templ_7745c5c3_Err != nil { return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/tpl/list.templ`, Line: 42, Col: 34} } _, 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(" цитат.") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } return templ_7745c5c3_Err }) templ_7745c5c3_Err = Layout(HeaderParams{ Title: "Цитатник Рунета", Description: "Новый цитатник Рунета", URL: host, }).Render(templ.WithChildren(ctx, templ_7745c5c3_Var2), templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } return templ_7745c5c3_Err }) } func generatePagination(currentPage, totalPages int) []string { pagination := make([]string, 0, 11) if currentPage <= 3 { for i := 0; i <= currentPage+3; i++ { pagination = append(pagination, strconv.Itoa(i)) } pagination = append(pagination, "...") pagination = append(pagination, strconv.Itoa(totalPages-2)) pagination = append(pagination, strconv.Itoa(totalPages-1)) pagination = append(pagination, strconv.Itoa(totalPages)) } else if currentPage >= totalPages-3 { pagination = append(pagination, "0") pagination = append(pagination, "1") pagination = append(pagination, "2") pagination = append(pagination, "...") for i := currentPage - 3; i <= totalPages; i++ { pagination = append(pagination, strconv.Itoa(i)) } } else { pagination = append(pagination, "0") pagination = append(pagination, "...") for i := currentPage - 2; i <= currentPage+2; i++ { pagination = append(pagination, strconv.Itoa(i)) } pagination = append(pagination, "...") pagination = append(pagination, strconv.Itoa(totalPages)) } return pagination } var _ = templruntime.GeneratedTemplate