discourse/app/views/email/notification.html.erb
David Battersby 17e6ea96ab
UX: add preview to email templates (#36657)
Adds a preview text to the beginning of the email body based on user
notification type. The value is taken from the translation key, which
can be customized for each email within Admin -> Appearance -> Site
Texts (ie. translation overrides).

For html emails this preview text is hidden with `display: none` to
prevent it appearing within the body of the email. For the plain text
version of the email it will appear within the body of the email.

Co-authored-by: Martin Brennan <martin@discourse.org>
2026-01-08 11:33:53 +04:00

50 lines
1.9 KiB
Text

<div id='main' class=<%= classes %>>
<%- if reply_above_line.present? %>
<div class="reply-above-line">
<%= t('user_notifications.reply_above_line') %>
</div>
<% end %>
<div class='email-preview'>%{email_preview}</div>
<div class='header-instructions'>%{header_instructions}</div>
<%- if SiteSetting.private_email? %>
<p><%= t('system_messages.contents_hidden') %></p>
<% else %>
<%= render partial: 'email/post', locals: { post: post, use_excerpt: SiteSetting.post_excerpts_in_emails } %>
<% if in_reply_to_post.present? || context_posts.present? %>
<div class='footer'>%{respond_instructions}</div>
<hr>
<% end %>
<% if in_reply_to_post.present? %>
<h4 class='previous-discussion'><%= t "user_notifications.in_reply_to" %></h4>
<%= render partial: 'email/post', locals: { post: in_reply_to_post, use_excerpt: true} %>
<% end %>
<% if context_posts.present? %>
<h4 class='previous-discussion'><%= t "user_notifications.previous_discussion" %></h4>
<% context_posts.each do |p| %>
<%= render partial: 'email/post', locals: { post: p, use_excerpt: false } %>
<% end %>
<% end %>
<% if reached_limit %>
<hr>
<div class='footer'><%= t "user_notifications.reached_limit", count: SiteSetting.max_emails_per_day_per_user %></div>
<% end %>
<% end %>
<div class='footer undecorated-link-footer <%= first_footer_classes %>'>%{respond_instructions}</div>
<div class='footer'>%{unsubscribe_instructions}</div>
</div>
<div itemscope itemtype="http://schema.org/EmailMessage" style="display:none">
<div itemprop="action" itemscope itemtype="http://schema.org/ViewAction">
<link itemprop="url" href="<%= Discourse.base_url %><%= post.url(without_slug: SiteSetting.private_email?) %>" />
<meta itemprop="name" content="<%= t 'read_full_topic' %>"/>
</div>
</div>