aboutsummaryrefslogtreecommitdiff
path: root/pkg/tpl/rate.templ
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/tpl/rate.templ')
-rw-r--r--pkg/tpl/rate.templ31
1 files changed, 31 insertions, 0 deletions
diff --git a/pkg/tpl/rate.templ b/pkg/tpl/rate.templ
new file mode 100644
index 0000000..bd63df8
--- /dev/null
+++ b/pkg/tpl/rate.templ
@@ -0,0 +1,31 @@
+package tpl
+
+import (
+ "fmt"
+ "sh.org.ru/pkg/model"
+ "strconv"
+)
+
+templ Rate(quote *model.Quote, act int) {
+ <nav class="rate">
+ <a
+ hx-post={ fmt.Sprintf("/rate/%d", quote.ID) }
+ hx-target="closest .rate"
+ hx-vals='{"vote": "up"}'
+ href="#"
+ >
+ <i class="fa fa-plus"></i>
+ </a>
+ &nbsp;
+ { strconv.Itoa(quote.Rating) }
+ &nbsp;
+ <a
+ hx-post={ fmt.Sprintf("/rate/%d", quote.ID) }
+ hx-target="closest .rate"
+ hx-vals='{"vote": "down"}'
+ href="#"
+ >
+ <i class="fa fa-minus"></i>
+ </a>
+ </nav>
+}