 Documentation
      ¶
      Documentation
      ¶
    
    
  
    
  
    Index ¶
- func GetTemplateByBytes(name string, data map[string]interface{}) ([]byte, error)
- func GetTemplateByString(name string, data map[string]interface{}) (string, error)
- func IsCommandAvailable(cmd string) bool
- func LoadTemplates(files embed.FS) error
- func LoadTemplatesFromDir(dir string) error
- func NewTemplateByString(format string, data map[string]interface{}) (string, error)
- type Data
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetTemplateByBytes ¶ added in v0.1.0
GetTemplateByBytes returns the parsed template as a byte slice. It returns an error if the template processing fails.
func GetTemplateByString ¶ added in v0.1.0
GetTemplateByString returns the parsed template as a string. It returns an error if the template processing fails.
func IsCommandAvailable ¶
IsCommandAvailable checks if a given command is available in the system's PATH. It takes a string argument 'cmd' which represents the command to check. It returns true if the command is found, otherwise false.
func LoadTemplates ¶
LoadTemplates loads all the templates found in the templates directory from the embedded filesystem. It returns an error if reading the directory or parsing any template fails.
func LoadTemplatesFromDir ¶ added in v0.16.0
LoadTemplatesFromDir loads all the templates found in the specified directory from the filesystem. It returns an error if reading the directory or parsing any template fails.
func NewTemplateByString ¶ added in v0.1.0
NewTemplateByString parses a template from a string and executes it with the provided data. It returns the resulting string or an error if the template parsing or execution fails.
Types ¶
type Data ¶
type Data map[string]interface{}
Data defines a custom type for the template data.
func ConvertToMap ¶ added in v0.2.1
ConvertToMap takes a slice of strings in the format "key=value" and converts it into a Data map. Each string in the slice is split into a key and value pair using the first occurrence of the "=" character. If a string does not contain the "=" character, it is ignored. The resulting map contains the keys and values from the input slice.
Args:
args ([]string): A slice of strings where each string is in the format "key=value".
Returns:
Data: A map where the keys and values are derived from the input slice.