Skip to content

gggwvg/gofuncmap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gofuncmap

Use golang functions in template

Usage

package main

import (
	"html/template"
	"os"

	"github.com/gggwvg/gofuncmap"
)

func main() {
	var (
		user = map[string]string{"Name": "www"}
		txt  = `My name is {{ .Name | toUpper }}`
	)
	tmpl, err := template.New("example").Funcs(gofuncmap.Funcs).Parse(txt)
	if err != nil {
		panic(err)
	}
	err = tmpl.Execute(os.Stdout, user)
	if err != nil {
		panic(err)
	}

	// Output:
	// My name is WWW
}

About

Use golang functions in template

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages