libdati
data and template interface
dati provides a unified interface for parsing data and templates. Ideally it will support all data and template languages, if it doesn't support one you want submit a PR or contact the developer. I've tried to make it easy to add support for new languages (provided a library to do the hard-work already exists).
It can be used as a Golang library or an executable tool, although it was built as a library first but works well in both forms.
dati library
The library is incredibly useful if you want to easily parse data and template languages without learning different interface / data structures for every library used for each supported language.
For documentation on the dati library:
pkg.go.dev/notabug.org/gearsix/libdati
or
go doc -all
in the directory of the dati repo
dati binary
The binary is intended to showcase what the library is useful for and be example of how to use it in your own software. It works perfectly well as a data-template executioner too though. It can parse data files and execute the parsed structure against templates with ease.
View dati/README to see documentation on using the dati binary.
View dati/dati.go to view the source of the binary and see how the dati library can be used.
supported formats / languages
supported data languages
Below is a list of the supported languages for data-serialisation.
- JSON (.json) see https://json.org/
- YAML (.yaml) see yamllint.com/
- TOML (.toml) see toml.io/
supported template language
These are the currently supported templating languages.
- mustache (.mu, .mustache) see mustache.github.io/
- golang text/template (.tmpl, .gotmpl) see golang.org/pkg/text/template/
- golang html/template (.hmpl, .gohmpl) see golang.org/pkg/html/template
- note that this and text/template are almost interchangable, with the exception that html/template will produce "HTML output safe against code injection".
acknowledgments
All of these libraries do the hard work, dati just combines them together - so thanks to the authors. Also here for reference.
- The Go standard library is used for parsing JSON, .tmpl/.gotmpl, .hmpl/.gohmpl
- github.com/pelletier/go-toml
- gopkg.in/yaml.v3
- github.com/cbroglie/mustache
AUTHORS
- gearsix