Documentation
¶
Overview ¶
SPDX-FileCopyrightText: 2025 Forkbomb BV
SPDX-License-Identifier: AGPL-3.0-or-later
SPDX-FileCopyrightText: 2025 Forkbomb BV
SPDX-License-Identifier: AGPL-3.0-or-later
SPDX-FileCopyrightText: 2025 Forkbomb BV
SPDX-License-Identifier: AGPL-3.0-or-later
Package templateengine provides functionality for rendering templates ¶
SPDX-FileCopyrightText: 2025 Forkbomb BV
SPDX-License-Identifier: AGPL-3.0-or-later
Index ¶
- func Funcs() template.FuncMap
- func GetPlaceholders(readers []io.Reader, names []string) (map[string]interface{}, error)
- func LoadYAML(filename string, v any) error
- func ParseEudiwInput(input, defaultFile string) ([]byte, error)
- func ParseEwcInput(input, defaultFile string) ([]byte, error)
- func ParseOpenidnetInput(input, defaultFile, configFile string) ([]byte, error)
- func RenderTemplate(reader io.Reader, data map[string]interface{}) (string, error)
- func ValidateVariant(variant map[string]string, config Config) error
- type Config
- type FieldRule
- type PlaceholderMetadata
- type TypeOfFieldType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Funcs ¶
Funcs returns the sprout functions available to Credimi templates.
It is sprout's "all" group without the env registry: templates can reach tenant-controlled input, and env/expandEnv would expose the process environment (server secrets) to whoever writes the template.
func GetPlaceholders ¶
GetPlaceholders processes a list of template readers and their corresponding names to extract placeholder metadata and organize it into normalized and specific fields.
func ParseEudiwInput ¶
ParseEudiwInput parses a YAML template file and updates both "id" and "nonce" fields using the provided input as a prefix for the credimi_id values. It mirrors the logic of ParseEwcInput but operates on two fields.
func ParseEwcInput ¶
func ParseOpenidnetInput ¶
func RenderTemplate ¶
RenderTemplate takes a reader containing a template and a data map, renders the template using the provided data, and returns the resulting string. It also preprocesses the template to handle custom placeholders and metadata extraction.
Types ¶
type PlaceholderMetadata ¶
type PlaceholderMetadata struct {
CredimiID string `json:"credimi_id"`
FieldID string `json:"field_id"`
FieldLabel string `json:"field_label"`
FieldDesc string `json:"field_description"`
FieldDefault interface{} `json:"field_default_value"`
FieldType TypeOfFieldType `json:"field_type"`
FieldOptions []string `json:"field_options"`
}
PlaceholderMetadata holds metadata for a placeholder in a template. It matches the placeholderInput struct.
func (*PlaceholderMetadata) GetDefaultValue ¶
func (p *PlaceholderMetadata) GetDefaultValue() string
GetDefaultValue returns the default value of the placeholder, if the original value is a string return a string, if is an object return a json string
type TypeOfFieldType ¶
type TypeOfFieldType string
const ( TypeOfFieldTypeString TypeOfFieldType = "string" TypeOfFieldTypeObject TypeOfFieldType = "object" TypeOfFieldTypeOptions TypeOfFieldType = "options" )