diff options
| author | Nikolaus Gotsche <n@softwarefools.com> | 2018-08-17 00:29:05 +0200 |
|---|---|---|
| committer | Nikolaus Gotsche <n@softwarefools.com> | 2018-08-17 00:29:05 +0200 |
| commit | ed43a6d9c450483914281e5fc3b6877116fc6ad0 (patch) | |
| tree | a740450f135ba25e3dcedf902f2ea1d7e6ec8f1f /texify.go | |
| parent | 9cd458d7d0a66074fe23e5a634b43ad9e9f4d1ef (diff) | |
First TeX Template playground
Diffstat (limited to 'texify.go')
| -rw-r--r-- | texify.go | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/texify.go b/texify.go new file mode 100644 index 0000000..53ca5b3 --- /dev/null +++ b/texify.go @@ -0,0 +1,39 @@ +package main + +import ( + "os" + "text/template" +) + +type Todo struct { + Name string + Adresse string + Number uint +} + +func tmpltest() { + + //Sampledata + td := Todo{"Jemand Wiadschosei", "123 Fakestreet 299",99} + + //Parse Templates + tmpl, err := template.New("invoice").Delims("[[","]]").ParseGlob("templates/*.tex") + checkErr(err) + //if err != nil { + // panic(err) + //} + //t, err := template.New("todos").Parse("You have a task named \"{{ .Name}}\" with description: \"{{ .Description}}\"") + //if err != nil { + // panic(err) + //} + //err = tmpl.Execute(os.Stdout, td) + //Open File + f, err := os.Create("outtex/1_data.tex") + checkErr(err) + defer f.Close() + + //Execute Template + //err = tmpl.ExecuteTemplate(os.Stdout, "invoice.tex", td) + err = tmpl.ExecuteTemplate(f, "_data.tex", td) + checkErr(err) +} |
