Apply inline styling to all <p> tags
Solved the problem of <p> tags being given different padding or color by different clients, without having to copy-paste a string of CSS into every <p> tag in the templates.
This commit is contained in:
parent
25d80789dd
commit
cf11913d58
3 changed files with 17 additions and 18 deletions
|
@ -18,4 +18,8 @@ module NotifierHelper
|
||||||
:locals => { :body => capture(&block) }
|
:locals => { :body => capture(&block) }
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def apply_inline_css(html)
|
||||||
|
html.gsub /<p>/, '<p style="color: black; margin: 0.75em 0">'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title></title>
|
|
||||||
<meta charset="UTF-8"></meta>
|
<meta charset="UTF-8"></meta>
|
||||||
</head>
|
</head>
|
||||||
<body style="padding: 0; margin: 0; font-size: 14px; font-family: 'Helvetica Neue', Arial, sans-serif; color: #222">
|
<body style="padding: 0; margin: 0; font-size: 14px; font-family: 'Helvetica Neue', Arial, sans-serif; color: #222">
|
||||||
|
@ -25,7 +24,7 @@
|
||||||
<table style="background-color: #fff; color: #222; border: solid 1px #ccc; border-collapse: separate">
|
<table style="background-color: #fff; color: #222; border: solid 1px #ccc; border-collapse: separate">
|
||||||
<tr>
|
<tr>
|
||||||
<td style="text-align: left; padding: 0px 15px 5px 15px">
|
<td style="text-align: left; padding: 0px 15px 5px 15px">
|
||||||
<%= yield %>
|
<%= raw apply_inline_css(yield) %>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
|
@ -1,21 +1,17 @@
|
||||||
<table style="font-size: 15px; font-style: italic; margin: 15px; background-color: #eee; width: 520px">
|
<table style="font-size: 15px; font-style: italic; margin: 15px; background-color: #eee; width: 520px">
|
||||||
<tr>
|
<tr>
|
||||||
<td style="width: 50px; vertical-align: top; padding: 5px 15px">
|
<td style="width: 50px; vertical-align: top; padding: 15px">
|
||||||
<%# Some email clients (e.g. Yahoo as of 2017-01) remove the margin
|
<%= link_to(
|
||||||
on <p> tags. Since the body itself always starts with a <p>, by
|
image_tag(
|
||||||
wrapping the image here in a <p> as well, we ensure that they will at
|
attachments["avatar.png"].url,
|
||||||
least always be aligned with each other. %>
|
alt: @author,
|
||||||
<p>
|
title: @author,
|
||||||
<%= link_to(
|
width: 50,
|
||||||
image_tag(
|
height: 50
|
||||||
attachments["avatar.png"].url,
|
),
|
||||||
alt: @author,
|
user_url(@author, :host => SERVER_URL),
|
||||||
title: @author
|
:target => "_blank"
|
||||||
),
|
) %>
|
||||||
user_url(@author, :host => SERVER_URL),
|
|
||||||
:target => "_blank"
|
|
||||||
) %>
|
|
||||||
</p>
|
|
||||||
</td>
|
</td>
|
||||||
<td style="text-align: left; vertical-align: top; padding-right: 10px">
|
<td style="text-align: left; vertical-align: top; padding-right: 10px">
|
||||||
<%= body %>
|
<%= body %>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue