Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix resolved header in email template #2878

Closed
wants to merge 1 commit into from

Conversation

nileger
Copy link

@nileger nileger commented Apr 5, 2022

Background

We use a custom email template based on alertmanager/template/email.tmpl.

Problem

The email template for resolved messages currently has a styling issue. Due to an extra </td>, the green heading is only shown in the top right corner, instead of covering the full width.

image

Solution

Removing the extra </td> solves the issue.

image

Signed-off-by: Nils Leger <nils.leger@gmail.com>
@nileger
Copy link
Author

nileger commented Apr 5, 2022

Can anyone help with the DCO check, please?

@simonpasquier
Copy link
Member

template/email.tmpl gets generated from template/email.html via the template/inline-css.js script which uses juice under the hood to inline the CSS properies into the style attributes.

IIUC juice is confused by this part and adds the extra </td>

{{ if gt (len .Alerts.Firing) 0 }}
<td class="alert alert-warning">
{{ else }}
<td class="alert alert-good">
{{ end }}
{{ .Alerts | len }} alert{{ if gt (len .Alerts) 1 }}s{{ end }} for {{ range .GroupLabels.SortedPairs }}
{{ .Name }}={{ .Value }}
{{ end }}
</td>

One way to fix it would be to duplicate the range loop like this:

 {{ if gt (len .Alerts.Firing) 0 }} 
 <td class="alert alert-warning"> 
   {{ .Alerts | len }} alert{{ if gt (len .Alerts) 1 }}s{{ end }} for {{ range .GroupLabels.SortedPairs }} 
     {{ .Name }}={{ .Value }}  
   {{ end }} 
 </td>
 {{ else }} 
 <td class="alert alert-good"> 
   {{ .Alerts | len }} alert{{ if gt (len .Alerts) 1 }}s{{ end }} for {{ range .GroupLabels.SortedPairs }} 
     {{ .Name }}={{ .Value }}  
   {{ end }} 
 </td>
 {{ end }} 

@cod-r
Copy link

cod-r commented Feb 27, 2023

Can this be merged? We are having the same problem and is annoying.

@simonpasquier
Copy link
Member

@cod-r this should be fixed in the latest v0.25.0 thanks to #3166

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants