Skip to content

Commit

Permalink
placeholder fix
Browse files Browse the repository at this point in the history
  • Loading branch information
8thgencore committed Jul 11, 2024
1 parent c715921 commit 2622f51
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
16 changes: 10 additions & 6 deletions Param.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,28 +100,32 @@ func (p *Param) SetValue(val any) {

// Placeholder .. {{Key}}
func (p *Param) Placeholder() string {
var formatter string = ""
var formatter, trigger, params string
if p.Formatter != nil {
formatter = p.Formatter.String()
}
var trigger string = ""
if p.Trigger != nil {
trigger = p.Trigger.String()
}
return "{{" + p.AbsoluteKey + " " + formatter + trigger + "}}"
if p.Formatter != nil || p.Trigger != nil {
params = " " + formatter + trigger
}
return "{{" + p.AbsoluteKey + params + "}}"
}

// PlaceholderKey .. {{#Key}}
func (p *Param) PlaceholderKey() string {
var formatter string = ""
var formatter, trigger, params string
if p.Formatter != nil {
formatter = p.Formatter.String()
}
var trigger string = ""
if p.Trigger != nil {
trigger = p.Trigger.String()
}
return "{{#" + p.AbsoluteKey + " " + formatter + trigger + "}}"
if p.Formatter != nil || p.Trigger != nil {
params = " " + formatter + trigger
}
return "{{#" + p.AbsoluteKey + params + "}}"
}

// PlaceholderInline .. {{Key ,}}
Expand Down
9 changes: 5 additions & 4 deletions Template.stage.funcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,16 @@ func (t *Template) expandPlaceholders(xnode *xmlNode) {
placeholderType = rowPlaceholder
}

var formatter string
var formatter, trigger, params string
if rowParam.Formatter != nil {
formatter = rowParam.Formatter.String()
}

var trigger string
if rowParam.Trigger != nil {
trigger = rowParam.Trigger.String()
}
if rowParam.Formatter != nil || rowParam.Trigger != nil {
params = " " + formatter + trigger
}

paramData := t.params.FindAllByKey(rowParam.AbsoluteKey)
if len(paramData) == 0 {
Expand All @@ -84,7 +85,7 @@ func (t *Template) expandPlaceholders(xnode *xmlNode) {
placeholders := make([]string, paramData[len(paramData)-1].Index)

for _, param := range paramData {
placeholders[param.Index-1] = "{{" + param.AbsoluteKey + " " + formatter + trigger + "}}"
placeholders[param.Index-1] = "{{" + param.AbsoluteKey + params + "}}"
}
rowPlaceholders[rowParam.RowPlaceholder] = &placeholder{
Type: placeholderType,
Expand Down

0 comments on commit 2622f51

Please sign in to comment.