tmpl

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 4, 2023 License: MIT Imports: 2 Imported by: 0

README

jet-helper

Jet is a template engine developed to be easy to use, powerful, dynamic, yet secure and very fast. jet-helper is a package to utilize Jet similarly to Golang text/template and html/template.

Usage Sample

import (
     tmpl "github.com/rosbit/jet-helper"
)

// sample 1
tmpls := tmpl.NewTempls(".")
t, err := tmpls.Lookup("index.jet")
if err != nil {
    // error processing
}
// t.Funcs(map[string]interface{}{})   // add Funcs like html/template::FuncMap
t.Execute(io.Writer, any)

// sample 2 to Parse text template
t, err := tmpl.Parse("text template as a string")
...

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	InDevelopmentMode = jet.InDevelopmentMode
	WithDelims        = jet.WithDelims
	WithSafeWriter    = jet.WithSafeWriter
	WithCache         = jet.WithCache
)

Functions

This section is empty.

Types

type Cache

type Cache = jet.Cache

type FuncMap

type FuncMap map[string]interface{}

type Option

type Option = jet.Option

type SafeWriter

type SafeWriter = jet.SafeWriter

type Template

type Template struct {
	*jet.Template
	*jet.Set
	// contains filtered or unexported fields
}

func Parse

func Parse(text string) (*Template, error)

func (*Template) Execute

func (t *Template) Execute(wr io.Writer, data interface{}) error

func (*Template) Funcs

func (t *Template) Funcs(funcMap FuncMap) *Template

type Tmpls

type Tmpls struct {
	*jet.Set
}

func NewTempls

func NewTempls(homeDir string, global ...FuncMap) *Tmpls

func (*Tmpls) Delims

func (ts *Tmpls) Delims(left, right string) *Tmpls

func (*Tmpls) ExecuteTemplate

func (ts *Tmpls) ExecuteTemplate(wr io.Writer, name string, data interface{}) error

func (*Tmpls) Lookup

func (ts *Tmpls) Lookup(name string) (*Template, error)

func (*Tmpls) Options

func (ts *Tmpls) Options(opts ...jet.Option) *Tmpls

Jump to

Keyboard shortcuts

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