errtemplate

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidName

func ValidName(name string) bool

ValidName 判断槽位名是否符合固定的小写 snake_case 规范。

Types

type Template

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

Template 是已经校验的简单具名模板。

func FromPattern

func FromPattern(pattern string, names []string) (Template, error)

FromPattern 将代码中的 %v/%% 模式转换为具名模板。

func Parse

func Parse(text string) (Template, error)

Parse 校验产品可编辑模板,仅接受普通文本和 {{.name}} 槽位。

func (Template) Render

func (template Template) Render(values map[string]any, unknown string) (string, []string)

Render 渲染模板。缺少的值只替换为 unknown,不破坏其余文案。

func (Template) Slots

func (template Template) Slots() []string

func (Template) Text

func (template Template) Text() string

Jump to

Keyboard shortcuts

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