Skip to content

Commit

Permalink
More tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rowanseymour committed Jul 4, 2024
1 parent 228c915 commit 1a52cdc
Show file tree
Hide file tree
Showing 2 changed files with 289 additions and 92 deletions.
5 changes: 2 additions & 3 deletions flows/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,15 @@ func (t *Template) FindTranslation(channel *Channel, locales []i18n.Locale) *Tem
return candidates[match]
}

// Templating generates a templating object for the passed in translation and variables
func (t *Template) Templating(tt *TemplateTranslation, vars []string) *MsgTemplating {
// cross-reference with asset to get variable types and filter out invalid values
// cross-reference with asset to get variable types and pad out any missing variables
variables := make([]*TemplatingVariable, len(tt.Variables()))
for i, v := range tt.Variables() {
// we pad out any missing variables with empty values
value := ""
if i < len(vars) {
value = vars[i]
}

variables[i] = &TemplatingVariable{Type: v.Type(), Value: value}
}

Expand Down
Loading

0 comments on commit 1a52cdc

Please sign in to comment.