summaryrefslogtreecommitdiff
path: root/templates
diff options
context:
space:
mode:
authorgabek <gabek@noreply@mills.io>2022-08-30 01:17:08 +0000
committerJames Mills <james@mills.io>2022-08-30 01:17:08 +0000
commit29f278459156f7bd9aec225ed78706d18e001c56 (patch)
tree1a1645c079e372ba96836fd63501a73b9e78b20b /templates
parent199aaa171f552719a7ac4c6539b921827de22d96 (diff)
Replace rice box with go embed (#25)
Reviewed-on: https://git.mills.io/prologic/tube/pulls/25 Co-authored-by: gabek <gabek@noreply@mills.io> Co-committed-by: gabek <gabek@noreply@mills.io>
Diffstat (limited to 'templates')
-rw-r--r--templates/templates.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/templates/templates.go b/templates/templates.go
new file mode 100644
index 0000000..2328b6e
--- /dev/null
+++ b/templates/templates.go
@@ -0,0 +1,17 @@
+package templates
+
+import (
+ "embed"
+)
+
+//go:embed *.html
+var templates embed.FS
+
+// MustGetTemplate returns a template string with the given name.
+func MustGetTemplate(name string) string {
+ b, err := templates.ReadFile(name)
+ if err != nil {
+ panic(err)
+ }
+ return string(b)
+}