From 29f278459156f7bd9aec225ed78706d18e001c56 Mon Sep 17 00:00:00 2001 From: gabek Date: Tue, 30 Aug 2022 01:17:08 +0000 Subject: Replace rice box with go embed (#25) Reviewed-on: https://git.mills.io/prologic/tube/pulls/25 Co-authored-by: gabek Co-committed-by: gabek --- templates/templates.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 templates/templates.go (limited to 'templates') 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) +} -- cgit v1.2.3