Skip to content

Commit

Permalink
fix(templates): restore resolving logic
Browse files Browse the repository at this point in the history
resolves #5848
  • Loading branch information
JanDeDobbeleer committed Nov 7, 2024
1 parent 5ec18f2 commit 84d132e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/config/segment.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,6 @@ func (segment *Segment) Execute(env runtime.Environment) {
return
}

if len(segment.Templates) != 0 {
segment.Template = segment.Templates.Resolve(segment.writer, "", segment.TemplatesLogic)
}

if segment.writer.Enabled() {
segment.Enabled = true
env.TemplateCache().AddSegmentData(segment.Name(), segment.writer)
Expand Down Expand Up @@ -277,6 +273,11 @@ func (segment *Segment) folderKey() string {
}

func (segment *Segment) string() string {
result := segment.Templates.Resolve(segment.writer, "", segment.TemplatesLogic)
if len(result) != 0 {
return result
}

if len(segment.Template) == 0 {
segment.Template = segment.writer.Template()
}
Expand Down Expand Up @@ -328,6 +329,10 @@ func (segment *Segment) evaluateNeeds() {
value += strings.Join(segment.BackgroundTemplates, "")
}

if len(segment.Templates) != 0 {
value += strings.Join(segment.Templates, "")
}

if !strings.Contains(value, ".Segments.") {
return
}
Expand Down
4 changes: 4 additions & 0 deletions src/template/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ func (l List) Empty() bool {
}

func (l List) Resolve(context any, defaultValue string, logic Logic) string {
if l.Empty() {
return defaultValue
}

switch logic {
case FirstMatch:
return l.FirstMatch(context, defaultValue)
Expand Down

0 comments on commit 84d132e

Please sign in to comment.