Documentation
¶
Index ¶
- type EncodingRegistry
- func (er *EncodingRegistry) Base32Decode(value string) (string, error)
- func (er *EncodingRegistry) Base32Encode(value string) string
- func (er *EncodingRegistry) Base64Decode(value string) (string, error)
- func (er *EncodingRegistry) Base64Encode(value string) string
- func (er *EncodingRegistry) FromJSON(value string) (any, error)
- func (er *EncodingRegistry) FromYAML(value string) (any, error)
- func (or *EncodingRegistry) LinkHandler(fh sprout.Handler) error
- func (er *EncodingRegistry) RegisterAliases(aliasesMap sprout.FunctionAliasMap) error
- func (er *EncodingRegistry) RegisterFunctions(funcsMap sprout.FunctionMap) error
- func (er *EncodingRegistry) RegisterNotices(notices *[]sprout.FunctionNotice) error
- func (er *EncodingRegistry) ToIndentYAML(indent int, value any) (out string, err error)
- func (er *EncodingRegistry) ToJSON(value any) (string, error)
- func (er *EncodingRegistry) ToPrettyJSON(value any) (string, error)
- func (er *EncodingRegistry) ToRawJSON(value any) (string, error)
- func (er *EncodingRegistry) ToYAML(value any) (out string, err error)
- func (or *EncodingRegistry) UID() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EncodingRegistry ¶
type EncodingRegistry struct {
// contains filtered or unexported fields
}
func NewRegistry ¶
func NewRegistry() *EncodingRegistry
NewRegistry creates a new instance of conversion registry.
func (*EncodingRegistry) Base32Decode ¶
func (er *EncodingRegistry) Base32Decode(value string) (string, error)
Base32Decode decodes a Base32 encoded string back to its original form. Returns an error message if the input is not valid Base32.
Parameters:
value string - the Base32 encoded string to decode.
Returns:
string - the decoded string, or an error message if the decoding fails. error - an error message if the decoding fails.
For an example of this function in a Go template, refer to Sprout Documentation: base32Decode.
func (*EncodingRegistry) Base32Encode ¶
func (er *EncodingRegistry) Base32Encode(value string) string
Base32Encode encodes a string into its Base32 representation.
Parameters:
value string - the string to encode.
Returns:
string - the Base32 encoded string.
For an example of this function in a Go template, refer to Sprout Documentation: base32Encode.
func (*EncodingRegistry) Base64Decode ¶
func (er *EncodingRegistry) Base64Decode(value string) (string, error)
Base64Decode decodes a Base64 encoded string back to its original form. Returns an error message if the input is not valid Base64.
Parameters:
value string - the Base64 encoded string to decode.
Returns:
string - the decoded string, or an error message if the decoding fails. error - an error message if the decoding fails.
For an example of this function in a Go template, refer to Sprout Documentation: base64Decode.
func (*EncodingRegistry) Base64Encode ¶
func (er *EncodingRegistry) Base64Encode(value string) string
Base64Encode encodes a string into its Base64 representation.
Parameters:
value string - the string to encode.
Returns:
string - the Base64 encoded string.
For an example of this function in a Go template, refer to Sprout Documentation: base64Encode.
func (*EncodingRegistry) FromJSON ¶ added in v1.0.0
func (er *EncodingRegistry) FromJSON(value string) (any, error)
FromJSON decodes a JSON string into a Go data structure, returning an error if decoding fails.
Parameters:
value string - the JSON string to decode.
Returns:
any - the decoded Go data structure. error - error encountered during decoding, if any.
For an example of this function in a Go template, refer to Sprout Documentation: fromJSON.
func (*EncodingRegistry) FromYAML ¶
func (er *EncodingRegistry) FromYAML(value string) (any, error)
FromYAML deserializes a YAML string into a Go map.
Parameters:
value string - the YAML string to deserialize.
Returns:
any - a map representing the YAML data. Returns nil if deserialization fails. error - an error message if the YAML content cannot be deserialized.
For an example of this function in a Go template, refer to Sprout Documentation: fromYaml.
func (*EncodingRegistry) LinkHandler ¶
func (or *EncodingRegistry) LinkHandler(fh sprout.Handler) error
LinkHandler links the handler to the registry at runtime.
func (*EncodingRegistry) RegisterAliases ¶ added in v0.6.0
func (er *EncodingRegistry) RegisterAliases(aliasesMap sprout.FunctionAliasMap) error
func (*EncodingRegistry) RegisterFunctions ¶
func (er *EncodingRegistry) RegisterFunctions(funcsMap sprout.FunctionMap) error
func (*EncodingRegistry) RegisterNotices ¶ added in v0.6.0
func (er *EncodingRegistry) RegisterNotices(notices *[]sprout.FunctionNotice) error
func (*EncodingRegistry) ToIndentYAML ¶ added in v1.0.0
func (er *EncodingRegistry) ToIndentYAML(indent int, value any) (out string, err error)
ToIndentYAML serializes a Go data structure to a YAML string and returns any error that occurs during the serialization. It allows to set an indentation width.
Parameters:
value any - the data structure to serialize. indent int - the indentation omitempty bool - omit empty fields (default: false)
Returns:
string - the YAML string representation of the data structure. error - error if the serialization fails.
For an example of this function in a Go template, refer to Sprout Documentation: toIndentYaml.
func (*EncodingRegistry) ToJSON ¶ added in v1.0.0
func (er *EncodingRegistry) ToJSON(value any) (string, error)
ToJSON encodes a Go data structure into a JSON string, returning an error if encoding fails.
Parameters:
value any - the Go data structure to encode.
Returns:
string - the JSON-encoded string. error - error encountered during encoding, if any.
For an example of this function in a Go template, refer to Sprout Documentation: toJSON.
func (*EncodingRegistry) ToPrettyJSON ¶ added in v1.0.0
func (er *EncodingRegistry) ToPrettyJSON(value any) (string, error)
ToPrettyJSON encodes a Go data structure into a pretty-printed JSON string, returning an error if encoding fails.
Parameters:
value any - the Go data structure to encode.
Returns:
string - the pretty-printed JSON string. error - error encountered during encoding, if any.
For an example of this function in a Go template, refer to Sprout Documentation: toPrettyJSON.
func (*EncodingRegistry) ToRawJSON ¶ added in v1.0.0
func (er *EncodingRegistry) ToRawJSON(value any) (string, error)
ToRawJSON encodes a Go data structure into a JSON string without escaping HTML, returning an error if encoding fails.
Parameters:
value any - the Go data structure to encode.
Returns:
string - the raw JSON string. error - error encountered during encoding, if any.
For an example of this function in a Go template, refer to Sprout Documentation: toRawJSON.
func (*EncodingRegistry) ToYAML ¶
func (er *EncodingRegistry) ToYAML(value any) (out string, err error)
ToYAML serializes a Go data structure to a YAML string and returns any error that occurs during the serialization.
Parameters:
value any - the data structure to serialize.
Returns:
string - the YAML string representation of the data structure. error - error if the serialization fails.
For an example of this function in a Go template, refer to Sprout Documentation: toYaml.
func (*EncodingRegistry) UID ¶ added in v1.0.0
func (or *EncodingRegistry) UID() string
UID returns the unique identifier of the registry.