aboutsummaryrefslogtreecommitdiff
path: root/page/misc.go
diff options
context:
space:
mode:
authorMitchell Riedstra <mitch@riedstra.dev>2021-07-18 16:27:24 -0400
committerMitchell Riedstra <mitch@riedstra.dev>2021-07-18 16:27:24 -0400
commitbcf6d391f17a193c81ad6643f8d006de6c6abad8 (patch)
treeb8eaec45b02d79f8d51d6726ffbbe34ce5de2ed7 /page/misc.go
parent904e37a88a6a2eab3919f7f2c40bbb2c07544a7c (diff)
downloadgo-website-0.0.13.tar.gz
go-website-0.0.13.tar.xz
Adjust the program a bit, remove clunky "head" templates. Add an example site among other improvementsv0.0.13
Diffstat (limited to 'page/misc.go')
-rw-r--r--page/misc.go31
1 files changed, 31 insertions, 0 deletions
diff --git a/page/misc.go b/page/misc.go
new file mode 100644
index 0000000..0dbd059
--- /dev/null
+++ b/page/misc.go
@@ -0,0 +1,31 @@
+package page
+
+import (
+ "encoding/json"
+
+ "gopkg.in/yaml.v3"
+)
+
+func (p Page) EncodeYaml(data interface{}) string {
+ if data == nil {
+ data = p
+ }
+
+ b, err := yaml.Marshal(data)
+ if err != nil {
+ Logger.Println("Encountered error in EncodeYaml: ", err)
+ }
+ return string(b)
+}
+
+func (p Page) EncodeJson(data interface{}) string {
+ if data == nil {
+ data = p
+ }
+
+ b, err := json.MarshalIndent(data, "", " ")
+ if err != nil {
+ Logger.Println("Encountered error in EncodeJson: ", err)
+ }
+ return string(b)
+}