aboutsummaryrefslogtreecommitdiff
path: root/pkg/tpl
diff options
context:
space:
mode:
authorAlexander Neonxp Kiryukhin <i@neonxp.ru>2024-10-12 02:52:22 +0300
committerAlexander Neonxp Kiryukhin <i@neonxp.ru>2024-10-12 02:53:52 +0300
commitd05ea66f4bbcf0cc5c8908f3435c68de1b070fa1 (patch)
tree7c7a769206646f2b81a0eda0680f0be5033a4197 /pkg/tpl
Начальная версияv0.0.1
Diffstat (limited to 'pkg/tpl')
-rw-r--r--pkg/tpl/error.templ10
-rw-r--r--pkg/tpl/error_templ.go86
-rw-r--r--pkg/tpl/error_templ.txt3
-rw-r--r--pkg/tpl/layout.templ49
-rw-r--r--pkg/tpl/layout_templ.go79
-rw-r--r--pkg/tpl/layout_templ.txt6
-rw-r--r--pkg/tpl/login.templ60
-rw-r--r--pkg/tpl/login_templ.go114
-rw-r--r--pkg/tpl/login_templ.txt6
-rw-r--r--pkg/tpl/profile.templ17
-rw-r--r--pkg/tpl/profile_templ.go86
-rw-r--r--pkg/tpl/profile_templ.txt3
-rw-r--r--pkg/tpl/register.templ63
-rw-r--r--pkg/tpl/register_templ.go114
-rw-r--r--pkg/tpl/register_templ.txt6
15 files changed, 702 insertions, 0 deletions
diff --git a/pkg/tpl/error.templ b/pkg/tpl/error.templ
new file mode 100644
index 0000000..0e0dcfa
--- /dev/null
+++ b/pkg/tpl/error.templ
@@ -0,0 +1,10 @@
+package tpl
+
+import "strconv"
+
+templ ErrorPage(code int, message string) {
+ @Layout() {
+ <h1>Ошибка { strconv.Itoa(code) }!</h1>
+ <p>{ message }</p>
+ }
+}
diff --git a/pkg/tpl/error_templ.go b/pkg/tpl/error_templ.go
new file mode 100644
index 0000000..04b4921
--- /dev/null
+++ b/pkg/tpl/error_templ.go
@@ -0,0 +1,86 @@
+// 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 "strconv"
+
+func ErrorPage(code int, message string) 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_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)
+ templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 1)
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ var templ_7745c5c3_Var3 string
+ templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(strconv.Itoa(code))
+ if templ_7745c5c3_Err != nil {
+ return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/tpl/error.templ`, Line: 7, Col: 39}
+ }
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3))
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 2)
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ var templ_7745c5c3_Var4 string
+ templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(message)
+ if templ_7745c5c3_Err != nil {
+ return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/tpl/error.templ`, Line: 8, Col: 14}
+ }
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4))
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 3)
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ return templ_7745c5c3_Err
+ })
+ templ_7745c5c3_Err = Layout().Render(templ.WithChildren(ctx, templ_7745c5c3_Var2), templ_7745c5c3_Buffer)
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ return templ_7745c5c3_Err
+ })
+}
+
+var _ = templruntime.GeneratedTemplate
diff --git a/pkg/tpl/error_templ.txt b/pkg/tpl/error_templ.txt
new file mode 100644
index 0000000..5d1d217
--- /dev/null
+++ b/pkg/tpl/error_templ.txt
@@ -0,0 +1,3 @@
+<h1>Ошибка
+!</h1><p>
+</p>
diff --git a/pkg/tpl/layout.templ b/pkg/tpl/layout.templ
new file mode 100644
index 0000000..4993b97
--- /dev/null
+++ b/pkg/tpl/layout.templ
@@ -0,0 +1,49 @@
+package tpl
+
+import "go.neonxp.ru/framework/pkg/utils"
+
+templ Layout() {
+ {{ user := utils.GetUserCtx(ctx) }}
+ <!DOCTYPE html>
+ <html lang="en">
+ <head>
+ <meta charset="utf-8"/>
+ <meta name="viewport" content="width=device-width, initial-scale=1"/>
+ <meta name="color-scheme" content="light dark"/>
+ <link rel="stylesheet" href="/css/pico/pico.blue.min.css"/>
+ <link rel="stylesheet" href="/css/style.css"/>
+ <link rel="stylesheet" href="/css/fork-awesome.min.css"/>
+ <title>App</title>
+ </head>
+ <body>
+ <main class="container">
+ <nav>
+ <ul>
+ <li><a href="/"><strong>App</strong></a></li>
+ <li><span aria-busy="true" id="loader" class="htmx-indicator">Загрузка...</span></li>
+ </ul>
+ <ul hx-boost="true" hx-indicator="#loader">
+ if user == nil {
+ <li><a href="/user/login">Вход</a></li>
+ <li><a href="/user/register">Регистрация</a></li>
+ } else {
+ <li><a href="/user/profile">{ user.Username }</a></li>
+ <li><a href="#" hx-post="/user/logout">Выход</a></li>
+ }
+ </ul>
+ </nav>
+ { children... }
+ </main>
+ </body>
+ <footer>
+ <main class="container">
+ <nav>
+ <ul>
+ <li>Сделал <a href="https://neonxp.ru/">NeonXP</a> в 2024 году.</li>
+ </ul>
+ </nav>
+ </main>
+ </footer>
+ <script src="/js/htmx.min.js"></script>
+ </html>
+}
diff --git a/pkg/tpl/layout_templ.go b/pkg/tpl/layout_templ.go
new file mode 100644
index 0000000..1edca5a
--- /dev/null
+++ b/pkg/tpl/layout_templ.go
@@ -0,0 +1,79 @@
+// 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 "go.neonxp.ru/framework/pkg/utils"
+
+func Layout() 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)
+ user := utils.GetUserCtx(ctx)
+ templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 1)
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ if user == nil {
+ templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 2)
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ } else {
+ templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 3)
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ var templ_7745c5c3_Var2 string
+ templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(user.Username)
+ if templ_7745c5c3_Err != nil {
+ return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/tpl/layout.templ`, Line: 30, Col: 50}
+ }
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2))
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 4)
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ }
+ templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 5)
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ templ_7745c5c3_Err = templ_7745c5c3_Var1.Render(ctx, templ_7745c5c3_Buffer)
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 6)
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ return templ_7745c5c3_Err
+ })
+}
+
+var _ = templruntime.GeneratedTemplate
diff --git a/pkg/tpl/layout_templ.txt b/pkg/tpl/layout_templ.txt
new file mode 100644
index 0000000..c6fb6f2
--- /dev/null
+++ b/pkg/tpl/layout_templ.txt
@@ -0,0 +1,6 @@
+<!doctype html><html lang=\"en\"><head><meta charset=\"utf-8\"><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"><meta name=\"color-scheme\" content=\"light dark\"><link rel=\"stylesheet\" href=\"/css/pico/pico.blue.min.css\"><link rel=\"stylesheet\" href=\"/css/style.css\"><link rel=\"stylesheet\" href=\"/css/fork-awesome.min.css\"><title>App</title></head><body><main class=\"container\"><nav><ul><li><a href=\"/\"><strong>App</strong></a></li><li><span aria-busy=\"true\" id=\"loader\" class=\"htmx-indicator\">Загрузка...</span></li></ul><ul hx-boost=\"true\" hx-indicator=\"#loader\">
+<li><a href=\"/user/login\">Вход</a></li><li><a href=\"/user/register\">Регистрация</a></li>
+<li><a href=\"/user/profile\">
+</a></li><li><a href=\"#\" hx-post=\"/user/logout\">Выход</a></li>
+</ul></nav>
+</main></body><footer><main class=\"container\"><nav><ul><li>Сделал <a href=\"https://neonxp.ru/\">NeonXP</a> в 2024 году.</li></ul></nav></main></footer><script src=\"/js/htmx.min.js\"></script></html>
diff --git a/pkg/tpl/login.templ b/pkg/tpl/login.templ
new file mode 100644
index 0000000..1f28e4d
--- /dev/null
+++ b/pkg/tpl/login.templ
@@ -0,0 +1,60 @@
+package tpl
+
+templ Login(form *LoginForm) {
+ @Layout() {
+ <article class="grid">
+ <div>
+ <hgroup>
+ <h1>Вход</h1>
+ <p>Вход в систему</p>
+ </hgroup>
+ <form
+ method="post"
+ hx-post="/user/login"
+ hx-target="form"
+ hx-select="form"
+ hx-indicator="#loader"
+ >
+ if form.Message != "" {
+ <article>
+ <header>Ошибка</header>
+ { form.Message }
+ </article>
+ }
+ <input
+ type="email"
+ name="email"
+ placeholder="Электропочта"
+ aria-label="Электропочта"
+ autocomplete="email"
+ value={ form.Email }
+ required
+ />
+ <input
+ type="password"
+ name="password"
+ placeholder="Пароль"
+ aria-label="Пароль"
+ autocomplete="current-password"
+ required
+ />
+ <fieldset>
+ <label for="remember">
+ <input type="checkbox" role="switch" id="remember" name="remember" checked={ form.Remember }/>
+ Запомнить
+ </label>
+ </fieldset>
+ <button type="submit" class="contrast">Вход</button>
+ </form>
+ </div>
+ <div></div>
+ </article>
+ }
+}
+
+type LoginForm struct {
+ Message string
+ Email string `form:"email"`
+ Password string `form:"password"`
+ Remember string `form:"remember"`
+}
diff --git a/pkg/tpl/login_templ.go b/pkg/tpl/login_templ.go
new file mode 100644
index 0000000..8c02424
--- /dev/null
+++ b/pkg/tpl/login_templ.go
@@ -0,0 +1,114 @@
+// 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"
+
+func Login(form *LoginForm) 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_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)
+ templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 1)
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ if form.Message != "" {
+ templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 2)
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ var templ_7745c5c3_Var3 string
+ templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(form.Message)
+ if templ_7745c5c3_Err != nil {
+ return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/tpl/login.templ`, Line: 21, Col: 21}
+ }
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3))
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 3)
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ }
+ templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 4)
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ var templ_7745c5c3_Var4 string
+ templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(form.Email)
+ if templ_7745c5c3_Err != nil {
+ return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/tpl/login.templ`, Line: 30, Col: 24}
+ }
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4))
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 5)
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ var templ_7745c5c3_Var5 string
+ templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(form.Remember)
+ if templ_7745c5c3_Err != nil {
+ return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/tpl/login.templ`, Line: 43, Col: 97}
+ }
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5))
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 6)
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ return templ_7745c5c3_Err
+ })
+ templ_7745c5c3_Err = Layout().Render(templ.WithChildren(ctx, templ_7745c5c3_Var2), templ_7745c5c3_Buffer)
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ return templ_7745c5c3_Err
+ })
+}
+
+type LoginForm struct {
+ Message string
+ Email string `form:"email"`
+ Password string `form:"password"`
+ Remember string `form:"remember"`
+}
+
+var _ = templruntime.GeneratedTemplate
diff --git a/pkg/tpl/login_templ.txt b/pkg/tpl/login_templ.txt
new file mode 100644
index 0000000..af8cbb3
--- /dev/null
+++ b/pkg/tpl/login_templ.txt
@@ -0,0 +1,6 @@
+<article class=\"grid\"><div><hgroup><h1>Вход</h1><p>Вход в систему</p></hgroup><form method=\"post\" hx-post=\"/user/login\" hx-target=\"form\" hx-select=\"form\" hx-indicator=\"#loader\">
+<article><header>Ошибка</header>
+</article>
+<input type=\"email\" name=\"email\" placeholder=\"Электропочта\" aria-label=\"Электропочта\" autocomplete=\"email\" value=\"
+\" required> <input type=\"password\" name=\"password\" placeholder=\"Пароль\" aria-label=\"Пароль\" autocomplete=\"current-password\" required><fieldset><label for=\"remember\"><input type=\"checkbox\" role=\"switch\" id=\"remember\" name=\"remember\" checked=\"
+\"> Запомнить</label></fieldset><button type=\"submit\" class=\"contrast\">Вход</button></form></div><div></div></article>
diff --git a/pkg/tpl/profile.templ b/pkg/tpl/profile.templ
new file mode 100644
index 0000000..61a9221
--- /dev/null
+++ b/pkg/tpl/profile.templ
@@ -0,0 +1,17 @@
+package tpl
+
+import "go.neonxp.ru/framework/pkg/model"
+
+templ Profile(user *model.User) {
+ @Layout() {
+ <article class="grid">
+ <div>
+ <hgroup>
+ <h1>{ user.Username }</h1>
+ <p>{ user.Email }</p>
+ </hgroup>
+ </div>
+ <div></div>
+ </article>
+ }
+}
diff --git a/pkg/tpl/profile_templ.go b/pkg/tpl/profile_templ.go
new file mode 100644
index 0000000..e51ab9a
--- /dev/null
+++ b/pkg/tpl/profile_templ.go
@@ -0,0 +1,86 @@
+// 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 "go.neonxp.ru/framework/pkg/model"
+
+func Profile(user *model.User) 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_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)
+ templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 1)
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ var templ_7745c5c3_Var3 string
+ templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(user.Username)
+ if templ_7745c5c3_Err != nil {
+ return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/tpl/profile.templ`, Line: 10, 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 = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 2)
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ var templ_7745c5c3_Var4 string
+ templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(user.Email)
+ if templ_7745c5c3_Err != nil {
+ return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/tpl/profile.templ`, Line: 11, Col: 20}
+ }
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4))
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 3)
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ return templ_7745c5c3_Err
+ })
+ templ_7745c5c3_Err = Layout().Render(templ.WithChildren(ctx, templ_7745c5c3_Var2), templ_7745c5c3_Buffer)
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ return templ_7745c5c3_Err
+ })
+}
+
+var _ = templruntime.GeneratedTemplate
diff --git a/pkg/tpl/profile_templ.txt b/pkg/tpl/profile_templ.txt
new file mode 100644
index 0000000..5fa238c
--- /dev/null
+++ b/pkg/tpl/profile_templ.txt
@@ -0,0 +1,3 @@
+<article class=\"grid\"><div><hgroup><h1>
+</h1><p>
+</p></hgroup></div><div></div></article>
diff --git a/pkg/tpl/register.templ b/pkg/tpl/register.templ
new file mode 100644
index 0000000..c7c7210
--- /dev/null
+++ b/pkg/tpl/register.templ
@@ -0,0 +1,63 @@
+package tpl
+
+templ Register(form *RegisterForm) {
+ @Layout() {
+ <article class="grid">
+ <div>
+ <hgroup>
+ <h1>Регистрация</h1>
+ <p>Регистрация в системе</p>
+ </hgroup>
+ <form
+ method="post"
+ hx-post="/user/register"
+ hx-target="form"
+ hx-select="form"
+ hx-indicator="#loader"
+ >
+ if form.Message != "" {
+ <article>
+ <header>Ошибка</header>
+ { form.Message }
+ </article>
+ }
+ <input
+ type="text"
+ name="username"
+ placeholder="Отображаемое имя"
+ aria-label="Отображаемое имя"
+ autocomplete="username"
+ value={ form.Username }
+ required
+ />
+ <input
+ type="email"
+ name="email"
+ placeholder="Электропочта"
+ aria-label="Электропочта"
+ autocomplete="email"
+ value={ form.Email }
+ required
+ />
+ <input
+ type="password"
+ name="password"
+ placeholder="Пароль"
+ aria-label="Пароль"
+ autocomplete="current-password"
+ required
+ />
+ <button type="submit" class="contrast">Регистрация</button>
+ </form>
+ </div>
+ <div></div>
+ </article>
+ }
+}
+
+type RegisterForm struct {
+ Message string
+ Username string `form:"username"`
+ Email string `form:"email"`
+ Password string `form:"password"`
+}
diff --git a/pkg/tpl/register_templ.go b/pkg/tpl/register_templ.go
new file mode 100644
index 0000000..ffab2de
--- /dev/null
+++ b/pkg/tpl/register_templ.go
@@ -0,0 +1,114 @@
+// 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"
+
+func Register(form *RegisterForm) 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_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)
+ templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 1)
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ if form.Message != "" {
+ templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 2)
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ var templ_7745c5c3_Var3 string
+ templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(form.Message)
+ if templ_7745c5c3_Err != nil {
+ return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/tpl/register.templ`, Line: 21, Col: 21}
+ }
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3))
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 3)
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ }
+ templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 4)
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ var templ_7745c5c3_Var4 string
+ templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(form.Username)
+ if templ_7745c5c3_Err != nil {
+ return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/tpl/register.templ`, Line: 30, Col: 27}
+ }
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4))
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 5)
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ var templ_7745c5c3_Var5 string
+ templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(form.Email)
+ if templ_7745c5c3_Err != nil {
+ return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/tpl/register.templ`, Line: 39, Col: 24}
+ }
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5))
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 6)
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ return templ_7745c5c3_Err
+ })
+ templ_7745c5c3_Err = Layout().Render(templ.WithChildren(ctx, templ_7745c5c3_Var2), templ_7745c5c3_Buffer)
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ return templ_7745c5c3_Err
+ })
+}
+
+type RegisterForm struct {
+ Message string
+ Username string `form:"username"`
+ Email string `form:"email"`
+ Password string `form:"password"`
+}
+
+var _ = templruntime.GeneratedTemplate
diff --git a/pkg/tpl/register_templ.txt b/pkg/tpl/register_templ.txt
new file mode 100644
index 0000000..c404586
--- /dev/null
+++ b/pkg/tpl/register_templ.txt
@@ -0,0 +1,6 @@
+<article class=\"grid\"><div><hgroup><h1>Регистрация</h1><p>Регистрация в системе</p></hgroup><form method=\"post\" hx-post=\"/user/register\" hx-target=\"form\" hx-select=\"form\" hx-indicator=\"#loader\">
+<article><header>Ошибка</header>
+</article>
+<input type=\"text\" name=\"username\" placeholder=\"Отображаемое имя\" aria-label=\"Отображаемое имя\" autocomplete=\"username\" value=\"
+\" required> <input type=\"email\" name=\"email\" placeholder=\"Электропочта\" aria-label=\"Электропочта\" autocomplete=\"email\" value=\"
+\" required> <input type=\"password\" name=\"password\" placeholder=\"Пароль\" aria-label=\"Пароль\" autocomplete=\"current-password\" required> <button type=\"submit\" class=\"contrast\">Регистрация</button></form></div><div></div></article>