templates

package
v0.5.4 Latest Latest
Warning

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

Go to latest
Published: May 26, 2020 License: BSD-3-Clause Imports: 17 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddGolangHelpers added in v0.3.0

func AddGolangHelpers(t *template.Template) *template.Template

func AddRaymondHelpers added in v0.3.0

func AddRaymondHelpers(t *raymond.Template) *raymond.Template

func Helper_add

func Helper_add(lhs, rhs int) int

func Helper_and

func Helper_and(lhs, rhs interface{}) interface{}

func Helper_builtin

func Helper_builtin(str string) interface{}

func Helper_camel

func Helper_camel(value string) string

func Helper_camelT

func Helper_camelT(value string) string

func Helper_concat2

func Helper_concat2(s1, s2 string) string

func Helper_concat3

func Helper_concat3(s1, s2, s3 string) string

func Helper_concat4

func Helper_concat4(s1, s2, s3, s4 string) string

func Helper_concat5

func Helper_concat5(s1, s2, s3, s4, s5 string) string

func Helper_contains

func Helper_contains(str, srch string) string

func Helper_dref_golang added in v0.3.2

func Helper_dref_golang(path string, data interface{}) interface{}

func Helper_dref_raymond added in v0.3.2

func Helper_dref_raymond(path string, data interface{}, options *raymond.Options) interface{}

func Helper_eq

func Helper_eq(lhs, rhs string) interface{}

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(value, indent string) string

func Helper_int_eq

func Helper_int_eq(lhs, rhs int) interface{}

func Helper_int_gt

func Helper_int_gt(lhs, rhs int) interface{}

func Helper_int_gte

func Helper_int_gte(lhs, rhs int) interface{}

func Helper_int_lt

func Helper_int_lt(lhs, rhs int) interface{}

func Helper_int_lte

func Helper_int_lte(lhs, rhs int) interface{}

func Helper_int_ne

func Helper_int_ne(lhs, rhs int) interface{}

func Helper_join2

func Helper_join2(sep, s1, s2 string) string

func Helper_join3

func Helper_join3(sep, s1, s2, s3 string) string

func Helper_join4

func Helper_join4(sep, s1, s2, s3, s4 string) string

func Helper_join5

func Helper_join5(sep, s1, s2, s3, s4, s5 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

func Helper_kebab

func Helper_kebab(value string) string

func Helper_kebabU

func Helper_kebabU(value string) string

func Helper_length

func Helper_length(list interface{}) interface{}

func Helper_listelem

func Helper_listelem(list interface{}, index int) interface{}

func Helper_lower

func Helper_lower(value string) string

func Helper_lwidth

func Helper_lwidth(width string, value string) string

func Helper_ne

func Helper_ne(lhs, rhs string) interface{}

func Helper_or

func Helper_or(lhs, rhs interface{}) interface{}

func Helper_pretty

func Helper_pretty(value interface{}) string

func Helper_printf

func Helper_printf(fmt_str string, args ...interface{}) string

func Helper_printf1

func Helper_printf1(fmt_str string, arg interface{}) string

func Helper_replace

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

func Helper_reverse

func Helper_reverse(list interface{}) interface{}

func Helper_rsublist

func Helper_rsublist(list interface{}, start, count int) interface{}

func Helper_rwidth

func Helper_rwidth(width string, value string) 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_string

func Helper_string(str string) string

func Helper_sublist

func Helper_sublist(list interface{}, start, count int) interface{}

func Helper_substr

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

func Helper_ternary

func Helper_ternary(first, second interface{}) interface{}

func Helper_thelist

func Helper_thelist(thing interface{}) interface{}

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_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 Config added in v0.2.9

type Config struct {

	// "global" Template parameters
	TemplateSystem string // which system ['text/template'(default), 'mustache']

	// Alt and Swap Delims,
	//   becuase the defaulttemplate systems use `{{` and `}}`
	//   and you may choose to use other delimiters, but the lookup system is still based on the template system
	//   and if you want to preserve those, we need three sets of delimiters
	AltDelims  bool
	SwapDelims bool

	// The default delimiters
	// You should change these when using alternative style like jinjas {% ... %}
	// They also need to be different when using the swap system
	LHS2_D string
	RHS2_D string
	LHS3_D string
	RHS3_D string

	// These are the same as the default becuase
	// the current template systems require these.
	//   So these should really never change or be overriden until there is a new template system
	//     supporting setting the delimiters dynamicalldelimiters dynamicallyy
	LHS2_S string
	RHS2_S string
	LHS3_S string
	RHS3_S string

	// The temporary delims to replace swap with while also swapping
	// the defaults you set to the swap that is required by the current templet systems
	// You need this when you are double templating a file and the top-level system is not the default
	LHS2_T string
	RHS2_T string
	LHS3_T string
	RHS3_T string
}

func LookupConfig added in v0.3.8

func LookupConfig(fn string, cfgs map[string]*Config) (*Config, error)

func (*Config) OverrideDotDefaults added in v0.2.9

func (D *Config) OverrideDotDefaults(delim *Config)

Override this Delim's dot defaults with 'delim' values

func (*Config) SwitchAfter added in v0.2.9

func (D *Config) SwitchAfter(content string) string

func (*Config) SwitchBefore added in v0.2.9

func (D *Config) SwitchBefore(content string) string

type Template

type Template struct {
	// Original inputs
	Name   string
	Source string
	Config *Config

	// golang
	T *template.Template

	// mustache
	R *raymond.Template
}

func CreateFromString added in v0.2.9

func CreateFromString(name, content, templateSystem string, config *Config) (t *Template, err error)

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

func NewTemplate

func NewTemplate() *Template

func (*Template) Render

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

type TemplateMap

type TemplateMap map[string]*Template

func CreateTemplateMapFromFolder

func CreateTemplateMapFromFolder(folder, system string, config *Config, configGlobs map[string]*Config) (tplMap TemplateMap, err error)

func NewMap

func NewMap() TemplateMap

func NewTemplateMap

func NewTemplateMap() TemplateMap

func (TemplateMap) ImportFromFolder

func (M TemplateMap) ImportFromFolder(folder, system string, config *Config, configGlobs map[string]*Config) error

func (TemplateMap) ImportTemplateFile

func (M TemplateMap) ImportTemplateFile(filename, system string, config *Config) error

Jump to

Keyboard shortcuts

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