1 Commits

Author SHA1 Message Date
Adrian Zürcher
9c2606f03d push all 2025-12-18 14:58:46 +01:00
3 changed files with 47 additions and 0 deletions

12
README.md Normal file
View File

@@ -0,0 +1,12 @@
# 🛠️ Go Template Builder
A lightweight, no-nonsense Go library to parse and render templates directly from files. Stop writing boilerplate for `text/template` and `html/template`—just point to a file, pass your data, and you're done.
---
## 📦 Installation
To use this package in your project, run:
```bash
go get [gitea.tecamino.com//paadi/template-builder](https://gitea.tecamino.com/paadi/template-builder)

3
go.mod Normal file
View File

@@ -0,0 +1,3 @@
module gitea.tecamino.com/paadi/template-builder.git
go 1.25.4

32
templateBuilder.go Normal file
View File

@@ -0,0 +1,32 @@
package templatebuilder
import (
"html/template"
"os"
)
type TemplateBuilder struct {
}
func NewTemplateBuilder() *TemplateBuilder {
return &TemplateBuilder{}
}
func (tb *TemplateBuilder) Generate(templatePath, outputFile string, data any) error {
tmpl, err := template.ParseFiles(templatePath)
if err != nil {
return err
}
f, err := os.Create(outputFile)
if err != nil {
return err
}
defer f.Close()
err = tmpl.Execute(f, data)
if err != nil {
return err
}
return nil
}