dati

A Go library/binary to parse & execute data against template langauges.
git clone git://src.gearsix.net/dati
Log | Files | Refs | Atom | README | LICENSE

commit 0e4cddcf6a8804b26750d62df47bc919ba60835c
parent d4297c1310ac97fe39f3ff757b857cc379f47de5
Author: gearsix <gearsix@tuta.io>
Date:   Fri,  3 Feb 2023 17:43:54 +0000

renamed Supported*Format

Diffstat:
Mdata.go | 20++++++++++----------
Mdata_test.go | 2+-
Mtemplate.go | 22+++++++++++-----------
Mtemplate_test.go | 2+-
4 files changed, 23 insertions(+), 23 deletions(-)

diff --git a/data.go b/data.go @@ -29,20 +29,20 @@ import ( "strings" ) -// SupportedDataFormat provides a list of supported languages for +// DataFormat provides a list of supported languages for // data files (lower-case) -type SupportedDataFormat string +type DataFormat string const ( - JSON SupportedDataFormat = "json" - YAML SupportedDataFormat = "yaml" - TOML SupportedDataFormat = "toml" + JSON DataFormat = "json" + YAML DataFormat = "yaml" + TOML DataFormat = "toml" ) -// ReadDataFormat returns the *SupportedDataFormat* that the file +// ReadDataFormat returns the *DataFormat* that the file // extension of `path` matches. If the file extension of `path` does -// not match any *SupportedDataFormat*, then an "" is returned. -func ReadDataFormat(path string) SupportedDataFormat { +// not match any *DataFormat*, then an "" is returned. +func ReadDataFormat(path string) DataFormat { if len(path) == 0 { return "" } @@ -53,7 +53,7 @@ func ReadDataFormat(path string) SupportedDataFormat { ext = ext[1:] } - for _, fmt := range []SupportedDataFormat{JSON, YAML, TOML} { + for _, fmt := range []DataFormat{JSON, YAML, TOML} { if string(fmt) == ext { return fmt } @@ -70,7 +70,7 @@ func IsSupportedDataLang(lang string) int { if len(lang) > 0 && lang[0] == '.' { lang = lang[1:] } - for i, l := range []SupportedDataFormat{JSON, YAML, TOML} { + for i, l := range []DataFormat{JSON, YAML, TOML} { if lang == string(l) { return i } diff --git a/data_test.go b/data_test.go @@ -65,7 +65,7 @@ func TestReadDataFormat(t *testing.T) { } for i, ext := range exts { - var target SupportedDataFormat + var target DataFormat if i < 4 { target = JSON diff --git a/template.go b/template.go @@ -31,20 +31,20 @@ import ( tmpl "text/template" ) -// SupportedTemplateFormat provides a list of supported languages for +// TemplateLanguage provides a list of supported languages for // Template files (lower-case) -type SupportedTemplateFormat string +type TemplateLanguage string const ( - TMPL SupportedTemplateFormat = "tmpl" - HMPL SupportedTemplateFormat = "hmpl" - MST SupportedTemplateFormat = "mst" + TMPL TemplateLanguage = "tmpl" + HMPL TemplateLanguage = "hmpl" + MST TemplateLanguage = "mst" ) -// ReadTemplateFormat returns the *SupportedTemplateFormat* that the file +// ReadTemplateFormat returns the *TemplateLanguage* that the file // extension of `path` matches. If the file extension of `path` does -// not match any *SupportedTemplateFormat*, then an "" is returned. -func ReadTemplateFormat(path string) SupportedTemplateFormat { +// not match any *TemplateLanguage*, then an "" is returned. +func ReadTemplateFormat(path string) TemplateLanguage { if len(path) == 0 { return "" } @@ -55,7 +55,7 @@ func ReadTemplateFormat(path string) SupportedTemplateFormat { ext = ext[1:] } - for _, fmt := range []SupportedTemplateFormat{TMPL, HMPL, MST} { + for _, fmt := range []TemplateLanguage{TMPL, HMPL, MST} { if string(fmt) == ext { return fmt } @@ -63,7 +63,7 @@ func ReadTemplateFormat(path string) SupportedTemplateFormat { return "" } -// **DEPRECIATED** please use SupportedTemplateFormat +// **DEPRECIATED** please use TemplateLanguage var SupportedTemplateLangs = []string{"tmpl", "hmpl", "mst"} // **DEPRECIATED** please use ReadTemplateFormat @@ -255,7 +255,7 @@ func loadTemplateMst(rootName string, root io.Reader, partials map[string]io.Rea func LoadTemplate(lang string, rootName string, root io.Reader, partials map[string]io.Reader) (t Template, e error) { t.Name = rootName - switch SupportedTemplateFormat(lang) { + switch TemplateLanguage(lang) { case TMPL: t.T, e = loadTemplateTmpl(rootName, root, partials) case HMPL: diff --git a/template_test.go b/template_test.go @@ -84,7 +84,7 @@ func TestReadTemplateFormat(t *testing.T) { } for i, ext := range exts { - var target SupportedTemplateFormat + var target TemplateLanguage if i < 4 { target = TMPL } else if i < 8 {