mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-26 22:04:32 +02:00
output: Rework the base template logic
Extract the logic to a testable function and add support for custom output types. Fixes #2995
This commit is contained in:
@@ -92,7 +92,7 @@ type Format struct {
|
||||
NoUgly bool
|
||||
}
|
||||
|
||||
func GetType(key string) (Format, bool) {
|
||||
func GetFormat(key string) (Format, bool) {
|
||||
found, ok := builtInTypes[key]
|
||||
if !ok {
|
||||
found, ok = builtInTypes[strings.ToLower(key)]
|
||||
@@ -101,11 +101,11 @@ func GetType(key string) (Format, bool) {
|
||||
}
|
||||
|
||||
// TODO(bep) outputs rewamp on global config?
|
||||
func GetTypes(keys ...string) (Formats, error) {
|
||||
func GetFormats(keys ...string) (Formats, error) {
|
||||
var types []Format
|
||||
|
||||
for _, key := range keys {
|
||||
tpe, ok := GetType(key)
|
||||
tpe, ok := GetFormat(key)
|
||||
if !ok {
|
||||
return types, fmt.Errorf("OutputFormat with key %q not found", key)
|
||||
}
|
||||
|
Reference in New Issue
Block a user