templateStr

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: May 22, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Any

type Any = interface{}

type Func

type Func func([]Any) string

type FuncArray

type FuncArray []Func

type TemplateStr

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

Construtor

func New

func New(funcArray FuncArray, variableMap VariableMap) TemplateStr

`funcArray FuncArray` is a array of custom functions that can be used when you call a function with: `{{@myCustomFunction}}`

`variableMap VariableMap` is a map of the values you want to use when you call: `{{$myVar}}`

Typing:

keyVariable  : is the key of the value in the dictionary pass to the constructor (return the value)
<b:True>     : bool    (return true)
<n:123>      : int     (return 123)
<n:123.4>    : float64 (return 123.4)
"text"       : string  (return text)

func (TemplateStr) HasCondition

func (t TemplateStr) HasCondition(text string) bool

Detects if there is the presence of `{{#var1 == var2: value1 || value2}}`

return -> bool

func (TemplateStr) HasFunction

func (t TemplateStr) HasFunction(text string) bool

Detects if there is the presence of `{{@function param1 param2}}` or `{{@function}}`

return -> bool

func (TemplateStr) HasOne

func (t TemplateStr) HasOne(text string) bool

Detects if there is the presence of min one syntaxe

return -> bool

func (TemplateStr) HasSwitch

func (t TemplateStr) HasSwitch(text string) bool

Detects if there is the presence of `{{?var: value1=#0F0, value2=#00F, ..., default=#000}}` or `{{?var:int; 56=#0F0, 32=#00F, ..., default=#000}}`

return -> bool

func (TemplateStr) HasVariable

func (t TemplateStr) HasVariable(text string) bool

Detects if there is the presence of `{{$variable}}`

return -> bool

func (TemplateStr) Parse

func (t TemplateStr) Parse(text string) string

shortcuts to run all parsers

return -> string

func (TemplateStr) ParseCondition

func (t TemplateStr) ParseCondition(text string) string

parse all the `{{#var1 == var2: value1 || value2}}` in the text give in

return -> string

func (TemplateStr) ParseFunction

func (t TemplateStr) ParseFunction(text string) string

parse all the `{{@function param1 param2}}` or `{{@function}}` in the text give in

return -> string

func (TemplateStr) ParseSwitch

func (t TemplateStr) ParseSwitch(text string) string

parse all the `{{?var; value1=#0F0, 56=#00F, ..., default=#000}}` or `{{?var:int; 56=#0F0, 32=#00F, ..., default=#000}}` in the text give in

return -> string

func (TemplateStr) ParseVariable

func (t TemplateStr) ParseVariable(text string) string

parse all the `{{$variable}}` in the text give in

return -> string

type VariableMap

type VariableMap map[string]Any

Jump to

Keyboard shortcuts

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