tmplutils

package
v0.0.17 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 18, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ProcessTemplFile

func ProcessTemplFile(templatePath, destPath string, funcMap template.FuncMap, data interface{}) error

ProcessTemplFile processes a template file with the provided data and writes the output to the destination file. It returns an error if any of the operations fail. The function map is used to define custom functions that can be called from the template.

Parameters:

  • templatePath: The path to the template file.
  • destPath: The path to the destination file where the processed template will be written.
  • funcMap: A map of custom functions that can be called from the template.
  • data: The data to be passed to the template for processing.

Returns:

  • error: An error if any of the operations fail.

Example:

funcMap := template.FuncMap{
    "toUpperCase": strings.ToUpper,
}
data := map[string]string{
    "Name": "John Doe",
}
err := ProcessTemplFile("template.tmpl", "output.txt", funcMap, data)
if err != nil {
    log.Fatalf("Error processing template file: %v", err)
}
fmt.Println("Template processed successfully.")

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL