template

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: May 8, 2026 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package template is the legacy server HTML-template import path.

New code should import the focused replacement package:

import "github.com/InsideGallery/core/server/view"

Compatibility: existing template exports remain available for downstream consumers that still import server/template. Prefer server/view.NewWithDir or server/view.NewFromOptions so template directory configuration is explicit and call sites avoid a local name collision with html/template.

Index

Constants

View Source
const DefaultTemplateDir = "DEFAULT_TEMPLATE_DIR"

DefaultTemplateDir have constant for template

Variables

View Source
var (
	ErrExecuteTemplate  = errors.New("error execute template")
	ErrNotFoundTemplate = errors.New("error not found template")
)

templates related errors

Functions

func GetDefaultTemplateDir deprecated

func GetDefaultTemplateDir(prefix string) string

GetDefaultTemplateDir return default template dir

Deprecated: pass the directory to NewTemplateWithDir or NewTemplateFromOptions.

func SetDefaultTemplateDir deprecated

func SetDefaultTemplateDir(prefix string, d string)

SetDefaultTemplateDir set default template dir

Deprecated: pass the directory to NewTemplateWithDir or NewTemplateFromOptions.

Types

type Engine

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

Engine type template engine

func NewEngine

func NewEngine() *Engine

NewEngine return engine

func (*Engine) Add

func (e *Engine) Add(t *Template)

Add add template

func (*Engine) Execute

func (e *Engine) Execute(name string, data interface{}) ([]byte, error)

Execute execute current template and return parsed string

func (*Engine) Exists

func (e *Engine) Exists(name string) bool

Exists return true if page exists

type Options added in v1.1.0

type Options struct {
	Name  string
	Dir   string
	Files []string
	FS    fs.FS
}

Options configures template parsing without environment state.

type Template

type Template struct {
	*template.Template
	Name string
}

Template describe template

func NewTemplate deprecated

func NewTemplate(name, prefix string, source fs.FS, files ...string) (*Template, error)

NewTemplate return new template

Deprecated: use NewTemplateWithDir or NewTemplateFromOptions with explicit directory config.

func NewTemplateBySource

func NewTemplateBySource(source embed.FS, name, pattern string) (*Template, error)

NewTemplateBySource return new template bu source

func NewTemplateFromOptions added in v1.1.0

func NewTemplateFromOptions(options Options) (*Template, error)

NewTemplateFromOptions returns a new template from explicit options.

func NewTemplateWithDir added in v1.1.0

func NewTemplateWithDir(name, dir string, source fs.FS, files ...string) (*Template, error)

NewTemplateWithDir returns a new template using an explicit base directory.

Jump to

Keyboard shortcuts

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