Configurable extensions for template parser

This commit is contained in:
Katrina Verey
2022-04-21 18:28:13 -04:00
parent 9d5491c2e2
commit bcae65770a
5 changed files with 42 additions and 10 deletions

View File

@@ -61,7 +61,7 @@ func TemplateStrings(data ...string) framework.TemplateParser {
// }},
// }
func TemplateFiles(paths ...string) TemplateParser {
return TemplateParser{parser{paths: paths, extension: TemplateExtension}}
return TemplateParser{parser{paths: paths, extensions: []string{TemplateExtension}}}
}
// TemplateParser is a framework.TemplateParser that can parse files or directories containing Go templated YAML.
@@ -95,3 +95,9 @@ func (l TemplateParser) FromFS(fs iofs.FS) TemplateParser {
l.parser.fs = fs
return l
}
// WithExtensions allows you to replace the extension the parser accept on the input files.
func (l TemplateParser) WithExtensions(ext ...string) TemplateParser {
l.parser.extensions = ext
return l
}