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: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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