diff --git a/main.go b/main.go index d3f5286..c9091d8 100644 --- a/main.go +++ b/main.go @@ -23,7 +23,8 @@ package main // import "git.sangeeth.dev/gobyexample/defers" // import "git.sangeeth.dev/gobyexample/recovering" // import "git.sangeeth.dev/gobyexample/stringfuncs" -import "git.sangeeth.dev/gobyexample/formatting" +// import "git.sangeeth.dev/gobyexample/formatting" +import "git.sangeeth.dev/gobyexample/templates" func main() { // runes.Runes() @@ -49,5 +50,6 @@ func main() { // defers.Defers() // recovering.Recover() // stringfuncs.StringFuncs() - formatting.Formatting() + // formatting.Formatting() + templates.Templates() } diff --git a/templates/templates.go b/templates/templates.go new file mode 100644 index 0000000..29b5148 --- /dev/null +++ b/templates/templates.go @@ -0,0 +1,43 @@ +package templates + +import ( + "fmt" + "os" + "strings" + "text/template" +) + +func CreateTemplate(label, content string) *template.Template { + return template.Must(template.New(label).Parse(content)) +} + +func Templates() { + t1 := CreateTemplate("bioList", ` +
{{ .Bio }}
+{{ if .IsAdult -}} Adult {{- else -}} Teen {{- end }}
+