templates

package
v0.6.9 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2024 License: Apache-2.0 Imports: 18 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Helper_add

func Helper_add(lhs, rhs int) int

func Helper_builtin

func Helper_builtin(str string) any

func Helper_camel

func Helper_camel(value string) string

func Helper_camelT

func Helper_camelT(value string) string

func Helper_concat added in v0.6.1

func Helper_concat(ss ...string) string

func Helper_contains

func Helper_contains(str, srch string) string

func Helper_dict added in v0.6.3

func Helper_dict(values ...interface{}) (map[string]interface{}, error)

func Helper_file added in v0.2.8

func Helper_file(filename string) string

func Helper_getbetween

func Helper_getbetween(str, lhs, rhs string) string

func Helper_getprefix

func Helper_getprefix(str, suf string) string

func Helper_getsuffix

func Helper_getsuffix(str, suf string) string

func Helper_gokind

func Helper_gokind(input interface{}) string

func Helper_hasprefix

func Helper_hasprefix(str, pre string) string

func Helper_hassuffix

func Helper_hassuffix(str, suf string) string

func Helper_identity

func Helper_identity(thing interface{}) interface{}

func Helper_inc

func Helper_inc(val int) int

func Helper_indent

func Helper_indent(indent interface{}, value string) string

Helper_indent indents lines of text, skipping the first line. The intended behavior is to match Helm's indent helper

func Helper_join added in v0.6.1

func Helper_join(sep string, ss ...string) string

func Helper_json

func Helper_json(value interface{}) string

func Helper_jsoninline added in v0.3.2

func Helper_jsoninline(value interface{}) string

jsonl too?

func Helper_kebab

func Helper_kebab(value string) string

func Helper_kebabU

func Helper_kebabU(value string) string

func Helper_lookup added in v0.6.4

func Helper_lookup(path string, data any) any

func Helper_lower

func Helper_lower(value string) string

func Helper_pascal added in v0.6.3

func Helper_pascal(value string) string

func Helper_pretty

func Helper_pretty(value interface{}) string

func Helper_replace

func Helper_replace(str, old, new string, cnt int) string

func Helper_snake

func Helper_snake(value string) string

func Helper_snakeU

func Helper_snakeU(value string) string

func Helper_split

func Helper_split(str, sep string) []string

func Helper_substr

func Helper_substr(str string, start, end int) string

func Helper_title

func Helper_title(value string) string

func Helper_toml

func Helper_toml(value interface{}) string

func Helper_trimfrom_first

func Helper_trimfrom_first(str, pre string, keep bool) string

func Helper_trimfrom_last

func Helper_trimfrom_last(str, pre string, keep bool) string

func Helper_trimprefix

func Helper_trimprefix(str, pre string) string

func Helper_trimspace added in v0.6.3

func Helper_trimspace(str string) string

func Helper_trimsuffix

func Helper_trimsuffix(str, suf string) string

func Helper_trimto_first

func Helper_trimto_first(str, pre string, keep bool) string

func Helper_trimto_last

func Helper_trimto_last(str, pre string, keep bool) string

func Helper_upper

func Helper_upper(value string) string

func Helper_xml

func Helper_xml(value interface{}) string

func Helper_yaml

func Helper_yaml(value interface{}) string

Types

type Delims added in v0.6.0

type Delims struct {
	LHS string
	RHS string
}

type Template

type Template struct {
	// Original inputs
	Name   string
	Source string
	Delims Delims

	// golang
	T *template.Template

	Buf *bytes.Buffer
}

func CreateFromString added in v0.2.9

func CreateFromString(name, content string, delims Delims) (t *Template, err error)

Creates a hof Template struct, initializing the correct template system. The system will be inferred if left empty

func (*Template) AddGolangHelpers added in v0.6.8

func (T *Template) AddGolangHelpers()

func (*Template) Helper_chat added in v0.6.8

func (T *Template) Helper_chat() func(string, ...map[string]any) any

returns the full response object

func (*Template) Helper_gen added in v0.6.8

func (T *Template) Helper_gen() any

returns just the message

func (*Template) Helper_render added in v0.6.9

func (T *Template) Helper_render() func(name string, data any) any

todo, should we support turning the content back to an objecct? perhaps better to have different functions for this

func (*Template) Render

func (T *Template) Render(data interface{}) ([]byte, error)

type TemplateMap

type TemplateMap map[string]*Template

func CreateTemplateMapFromFolder

func CreateTemplateMapFromFolder(glob, prefix string, delims Delims, delimMap map[string]Delims) (tplMap TemplateMap, err error)

func NewTemplateMap

func NewTemplateMap() TemplateMap

func (TemplateMap) ImportFromFolder

func (M TemplateMap) ImportFromFolder(glob, prefix string, delims Delims, delimMap map[string]Delims) error

func (TemplateMap) ImportTemplateFile

func (M TemplateMap) ImportTemplateFile(filename string, delims Delims) error

Jump to

Keyboard shortcuts

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