tmpl

package
v3.11.7 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2024 License: MIT Imports: 4 Imported by: 2

Documentation

Overview

Package tmpl contains functions for defining or executing in-line templates.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Template

type Template struct {
	// contains filtered or unexported fields
}

Template -

func New

func New(root *template.Template, tctx interface{}, path string) *Template

New -

func (*Template) Exec

func (t *Template) Exec(name string, tmplcontext ...interface{}) (string, error)

Exec - execute (render) a template - this is the built-in `template` action, except with output...

func (*Template) Inline

func (t *Template) Inline(args ...interface{}) (string, error)

Inline - a template function to do inline template processing

Can be called 4 ways: {{ tmpl.Inline "inline template" }} - unnamed (single-use) template with default context {{ tmpl.Inline "name" "inline template" }} - named template with default context {{ tmpl.Inline "inline template" $foo }} - unnamed (single-use) template with given context {{ tmpl.Inline "name" "inline template" $foo }} - named template with given context

func (*Template) Path added in v3.11.0

func (t *Template) Path() (string, error)

Path - returns the path to the current template if it came from a file. An empty string is returned for inline templates.

func (*Template) PathDir added in v3.11.0

func (t *Template) PathDir() (string, error)

PathDir - returns the directory of the template, if it came from a file. An empty string is returned for inline templates. If the template was loaded from the current working directory, "." is returned.

Jump to

Keyboard shortcuts

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