aboutsummaryrefslogtreecommitdiff
path: root/pkg/tpl/random_templ.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/tpl/random_templ.go')
-rw-r--r--pkg/tpl/random_templ.go45
1 files changed, 7 insertions, 38 deletions
diff --git a/pkg/tpl/random_templ.go b/pkg/tpl/random_templ.go
index 19a7035..79f5685 100644
--- a/pkg/tpl/random_templ.go
+++ b/pkg/tpl/random_templ.go
@@ -8,9 +8,9 @@ package tpl
import "github.com/a-h/templ"
import templruntime "github.com/a-h/templ/runtime"
-import "sh.org.ru/pkg/model"
-import "math/rand"
-import "fmt"
+import (
+ "sh.org.ru/pkg/model"
+)
func Random(quotes []model.Quote) templ.Component {
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
@@ -33,44 +33,13 @@ func Random(quotes []model.Quote) templ.Component {
templ_7745c5c3_Var1 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
- 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(" <a role=\"button\" href=\"")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- var templ_7745c5c3_Var3 templ.SafeURL = templ.URL(fmt.Sprintf("/random?%d", rand.Int()))
- _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(string(templ_7745c5c3_Var3)))
+ 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("\">Обновить</a>")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- return templ_7745c5c3_Err
- })
- templ_7745c5c3_Err = Layout(HeaderParams{
- Title: "Цитатник Рунета -- случайные",
- Description: "Новый цитатник Рунета",
- URL: "https://sh.org.ru/random",
- }).Render(templ.WithChildren(ctx, templ_7745c5c3_Var2), templ_7745c5c3_Buffer)
+ }
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<a role=\"button\" hx-get=\"/random\" hx-swap=\"outerHTML\">Загрузить ещё...</a>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}