diff --git a/static/frontend/search/search.tmpl b/static/frontend/search/search.tmpl index 235105b8c..f699dcd82 100644 --- a/static/frontend/search/search.tmpl +++ b/static/frontend/search/search.tmpl @@ -113,11 +113,7 @@ {{with $v.ChipText}}{{.}}{{end}} - {{range $v.Vulns}} - - {{.ID}} - - {{end}} + {{template "vuln-chip-condensed" $v.Vulns}} {{with $v.Synopsis}}

diff --git a/static/frontend/unit/versions/versions.tmpl b/static/frontend/unit/versions/versions.tmpl index 77432d19d..2b22f6d6b 100644 --- a/static/frontend/unit/versions/versions.tmpl +++ b/static/frontend/unit/versions/versions.tmpl @@ -78,7 +78,7 @@ {{else}}

{{$v.CommitTime}}{{if $v.Retracted}}
retracted
{{end}} - {{range $v.Vulns}}
{{.ID}}
{{end}} + {{template "vuln-chip-condensed-div" $v.Vulns}}
{{end}} {{end}} @@ -90,7 +90,7 @@
{{.CommitTime}}{{if .Retracted}}
retracted
{{end}} - {{range .Vulns}}{{.ID}}{{end}} + {{template "vuln-chip-condensed" .Vulns}}
{{range .Vulns}}{{template "vuln-message" .}}{{end}} diff --git a/static/shared/vuln/vuln.tmpl b/static/shared/vuln/vuln.tmpl index 40a03a679..71df6074e 100644 --- a/static/shared/vuln/vuln.tmpl +++ b/static/shared/vuln/vuln.tmpl @@ -16,3 +16,34 @@ {{.ID}}: {{.Details}}
{{end}} + +{{define "vuln-chip"}} + {{.}} +{{end}} + +{{define "vuln-chip-first"}} + {{template "vuln-chip" (index . 0).ID}} +{{end}} + +{{define "vuln-chip-more"}} + {{$more := (subtract (len .) 1)}} + {{template "vuln-chip" (printf "+%d more" $more)}} +{{end}} + +{{define "vuln-chip-condensed"}} + {{if .}} + {{template "vuln-chip-first" .}} + {{end}} + {{if (gt (len .) 1)}} + {{template "vuln-chip-more" .}} + {{end}} +{{end}} + +{{define "vuln-chip-condensed-div"}} + {{if .}} +
{{template "vuln-chip-first" .}}
+ {{end}} + {{if (gt (len .) 1)}} +
{{template "vuln-chip-more" .}}
+ {{end}} +{{end}}