aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/templates.go
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2025-08-03 02:29:50 +0200
committerThomas Voss <mail@thomasvoss.com> 2025-08-03 02:29:50 +0200
commit334a4ffe59286c0ca1d605b9a89155cbf2aa1eae (patch)
tree4fb8ba62162fe9ebccfd4edce605695ca81a62c0 /src/templates.go
parentcd8e44e6251e7fee2facaa225e52537eb2ecf4a5 (diff)
Improve table styling on mobile
Diffstat (limited to 'src/templates.go')
-rw-r--r--src/templates.go14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/templates.go b/src/templates.go
index 2721f92..a553766 100644
--- a/src/templates.go
+++ b/src/templates.go
@@ -120,7 +120,10 @@ func ifElse(b bool, x, y any) any {
return y
}
-func withTranslation(tag, bcp, text string, trans template.HTML) template.HTML {
+func withTranslation(tag, bcp, text string, trans template.HTML,
+ spanAttrs ...string) template.HTML {
+ name, _, _ := strings.Cut(tag, " ")
+
var bob strings.Builder
bob.WriteByte('<')
bob.WriteString(tag)
@@ -131,13 +134,18 @@ func withTranslation(tag, bcp, text string, trans template.HTML) template.HTML {
bob.WriteString("</span>")
if text != string(trans) {
- bob.WriteString(`<br><span class="translation">`)
+ bob.WriteString(`<br><span class="translation"`)
+ for _, s := range spanAttrs {
+ bob.WriteByte(' ')
+ bob.WriteString(s)
+ }
+ bob.WriteByte('>')
bob.WriteString(string(trans))
bob.WriteString("</span>")
}
bob.WriteString("</")
- bob.WriteString(tag)
+ bob.WriteString(name)
bob.WriteByte('>')
return template.HTML(bob.String())
}