Skip to content

Commit

Permalink
fix: unescape template
Browse files Browse the repository at this point in the history
  • Loading branch information
axetroy committed Nov 23, 2020
1 parent 3d14c9c commit e118cbf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
7 changes: 6 additions & 1 deletion 4_generator/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ func Generate(g *client.GitClient, contexts []*transform.TemplateContext) ([]byt
for _, ctx := range contexts {
t := template.New(ctx.Version)

t.Funcs(template.FuncMap{"StringsJoin": strings.Join})
t.Funcs(template.FuncMap{
"stringsJoin": strings.Join,
"unescape": func(s string) template.HTML {
return template.HTML(s)
},
})

if t, err := t.Parse(defaultTemplate); err != nil {
return nil, errors.WithStack(err)
Expand Down
8 changes: 4 additions & 4 deletions 4_generator/template_default.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const defaultTemplate = `# {{ .Version }}
{{- define "body" -}}
{{range . -}}
- {{if .Field.Header.Scope }}**{{ .Field.Header.Scope }}**: {{ end }}{{ .Field.Header.Subject }}({{.Short}}) (thanks @{{ .Author.Name }}){{if .Field.Footer }} {{if .Field.Footer.Closes }}, Closes: {{ StringsJoin .Field.Footer.Closes "," }} {{- end }} {{- end}}
- {{if .Field.Header.Scope }}**{{ unescape .Field.Header.Scope }}**: {{ end }}{{ unescape .Field.Header.Subject }}({{.Short}}) (thanks @{{ unescape .Author.Name }}){{if .Field.Footer }} {{if .Field.Footer.Closes }}, Closes: {{ stringsJoin .Field.Footer.Closes "," }} {{- end }} {{- end}}
{{ end }}
{{- end -}}
{{if .Feat}}
Expand Down Expand Up @@ -34,12 +34,12 @@ const defaultTemplate = `# {{ .Version }}
{{if .BreakingChanges}}
### BREAKING CHANGES:
{{ range .BreakingChanges -}}
- {{if .Field.Footer.BreakingChange.Title}}{{ .Field.Footer.BreakingChange.Title }}{{ else }}{{ .Field.Title }}{{ end }}
{{ .Field.Footer.BreakingChange.Content }}
- {{if .Field.Footer.BreakingChange.Title}}{{ unescape .Field.Footer.BreakingChange.Title }}{{ else }}{{ unescape .Field.Title }}{{ end }}
{{ unescape .Field.Footer.BreakingChange.Content }}
{{- end -}}
{{- end}}
### Commits({{ len .Commits }}):
{{range .Commits -}}
- **{{ .Short }}** {{ .Field.Title }}
- **{{ .Short }}** {{ unescape .Field.Title }}
{{ end }}`

0 comments on commit e118cbf

Please sign in to comment.