31 lines
633 B
Go
31 lines
633 B
Go
package template
|
|
|
|
import "fmt"
|
|
|
|
// CodecType represents the type of codec used to encode/render a value
|
|
type CodecType string
|
|
|
|
const (
|
|
CodecText CodecType = "text"
|
|
CodecNumber CodecType = "number"
|
|
CodecYaml CodecType = "yaml"
|
|
CodecList CodecType = "list"
|
|
CodecConst CodecType = "const"
|
|
)
|
|
|
|
func parseCodecType(input string) (CodecType, error) {
|
|
switch input {
|
|
case "number":
|
|
return CodecNumber, nil
|
|
case "yaml":
|
|
return CodecYaml, nil
|
|
case "list":
|
|
return CodecList, nil
|
|
case "text":
|
|
return CodecText, nil
|
|
case "const":
|
|
return CodecConst, nil
|
|
}
|
|
return CodecText, fmt.Errorf("unknown codec: '%s'", input)
|
|
}
|