fix(templates): do not replace a literal dot

resolves #2956
This commit is contained in:
Jan De Dobbeleer 2022-10-17 20:14:18 +02:00 committed by Jan De Dobbeleer
parent 016dc50e72
commit dee6d18baf
2 changed files with 8 additions and 0 deletions

View file

@ -82,6 +82,9 @@ func (t *Text) cleanTemplate() {
}
knownVariable := func(variable string) bool {
if variable == "." {
return true
}
variable = strings.TrimPrefix(variable, ".")
splitted := strings.Split(variable, ".")
if len(splitted) == 0 {

View file

@ -225,6 +225,11 @@ func TestCleanTemplate(t *testing.T) {
Expected string
Template string
}{
{
Case: "Literal dot",
Expected: "hello . what's up",
Template: "hello . what's up",
},
{
Case: "Variable",
Expected: "{{range $cpu := .Data.CPU}}{{round $cpu.Mhz 2 }} {{end}}",