Documentation ¶
Index ¶
- Constants
- Variables
- type Param
- func (p *Param) Depth() int
- func (p *Param) Placeholder() string
- func (p *Param) PlaceholderInline() string
- func (p *Param) PlaceholderKey() string
- func (p *Param) PlaceholderKeyInline() string
- func (p *Param) PlaceholderKeyPrefix() string
- func (p *Param) PlaceholderKeyWithTrigger() string
- func (p *Param) PlaceholderPrefix() string
- func (p *Param) PlaceholderWithTrigger() string
- func (p *Param) RunTrigger(xnode *xmlNode)
- func (p *Param) SetValue(val interface{})
- func (p *Param) String() string
- func (p *Param) ToCompact(placeholder string) string
- func (p *Param) Walk(fn func(*Param))
- type ParamList
- type ParamTrigger
- type Template
Constants ¶
const ( TriggerOnUnknown string = ":unknown" TriggerOnEmpty string = ":empty" TriggerOnValue string = ":=" )
On - trigger events when command to aply
const ( TriggerCommandRemove = ":remove" TriggerCommandClear = ":clear" )
Command - what to do when triggered
const ( TriggerScopePlaceholder = ":placeholder" TriggerScopeCell = ":cell" TriggerScopeRow = ":row" TriggerScopeList = ":list" TriggerScopeTable = ":table" TriggerScopeSection = ":section" // table, list.. )
Scope - scope of affected elements by command
const ParamPattern = `{{(#|)([\w\.]+?)(| .+?)(| [:a-z]+?)}}`
ParamPattern - regex pattern to identify params
const RemoveThisPlaceholder = "remove_this_placeholder"
Variables ¶
var NodeCellTypes = []string{"w-tc"}
NodeCellTypes - NB! sequence is important
var NodeRowTypes = []string{"w-tr", "w-p"}
NodeRowTypes - NB! sequence is important
var NodeSectionTypes = []string{"w-tbl", "w-p"}
NodeSectionTypes - NB! sequence is important
var NodeSingleTypes = []string{"w-r", "w-t"}
NodeSingleTypes - NB! sequence is important
Functions ¶
This section is empty.
Types ¶
type Param ¶
type Param struct { Key string Value string IsSlice bool // mark param created from slice Params ParamList AbsoluteKey string // Users.1.Name CompactKey string // Users.Name Separator string // {{Usernames SEPERATOR}} Trigger *ParamTrigger // contains filtered or unexported fields }
Param ..
func (*Param) PlaceholderInline ¶
PlaceholderInline .. {{Key ,}}
func (*Param) PlaceholderKeyInline ¶
PlaceholderKeyInline .. {{#Key ,}}
func (*Param) PlaceholderKeyPrefix ¶
PlaceholderKeyPrefix .. {{Key.
func (*Param) PlaceholderKeyWithTrigger ¶
PlaceholderKeyWithTrigger .. {{#Key :empty:remove:list}}
func (*Param) PlaceholderPrefix ¶
PlaceholderPrefix .. {{Key.
func (*Param) PlaceholderWithTrigger ¶
PlaceholderWithTrigger .. {{Key :empty:remove:list}}
type ParamList ¶
type ParamList []*Param
ParamList ..
func StructParams ¶
func StructParams(v interface{}) ParamList
StructParams - load params from given any struct 1) Convert struct to JSON 2) Now convert JSON to map[string]interface{} 3) Clear params from nil
type ParamTrigger ¶
type ParamTrigger struct { On string Command string Scope string // contains filtered or unexported fields }
ParamTrigger - param trigger command {{Key :On:Command:Scope}} {{MyParam :empty:remove:list}} -- Read as: "`remove` `list` on `empty` value"
func NewParamTrigger ¶
func NewParamTrigger(raw []byte) *ParamTrigger
NewParamTrigger - take raw ":empty:remove:list" and make trigger and it's fields from it
func (*ParamTrigger) String ¶
func (tr *ParamTrigger) String() string
String - return rebuilt trigger string
type Template ¶
type Template struct {
// contains filtered or unexported fields
}
Template ..
func (*Template) Bytes ¶
Bytes - create docx archive but return only bytes of it do not save it anywhere
func (*Template) ExportDocx ¶
ExportDocx - save new/modified docx based on template
func (*Template) Params ¶
func (t *Template) Params(v interface{})
Params - replace template placeholders with params "Hello {{ Name }}!"" --> "Hello World!""
func (*Template) Placeholders ¶
Placeholders - get list of used params placeholders in template If you already replaced params with values then you will not get all placeholders. Or use it after replace and see how many placeholders left.