views

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2024 License: BSD-3-Clause Imports: 15 Imported by: 0

README

views


   v := views.New(views.Config{
		Dir:        "./examples",
		Extensions: []string{".tmpl"},
		Compress:   true,
		Dev:        false,

		VersionFilePatch: "./examples/version.txt",
		VersionSize:      12,

		Log: func(str string) {
			log.Println(str)
		},
	})

	

	if err := v.Load(); err != nil {
		log.Fatalln("views load", err)
	}

	if err := v.Execute(os.Stdout, "child.tmpl", nil); err != nil {
		log.Fatalln("views Execute", err)
	}


PASS
coverage:  79.7% of statements
ok      views   0.279s

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	//Dir specifies the path to the directory with templates
	Dir string

	//Extensions specifies what file extensions the templates have
	Extensions []string

	//Compress specifies whether to compress templates
	//true - compresses templates during parsing
	//false - does not compress templates
	Compress bool

	//Dev enable/disable development mode
	//true  - parses templates every time
	//false - parses templates once at the very beginning
	Dev bool

	Log              LogFunc
	VersionFilePatch string
	VersionSize      int
}

type LogFunc added in v1.1.0

type LogFunc func(string)

type Views

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

func New

func New(cfg Config) *Views

func (*Views) Execute

func (v *Views) Execute(wr io.Writer, name string, data interface{}) error

func (*Views) Func

func (v *Views) Func(fn template.FuncMap) error

func (*Views) Load

func (v *Views) Load() error

Jump to

Keyboard shortcuts

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