Skip to content

Unified email wrapper for welcome and newsletter emails#26898

Open
9larsons wants to merge 5 commits intomainfrom
unify-wrapper-emails
Open

Unified email wrapper for welcome and newsletter emails#26898
9larsons wants to merge 5 commits intomainfrom
unify-wrapper-emails

Conversation

@9larsons
Copy link
Contributor

@9larsons 9larsons commented Mar 19, 2026

ref https://linear.app/ghost/issue/NY-1168/

  • moved to single wrapper .hbs for emails (member welcome emails, newsletters); welcome emails brought into line with newsletters

Ideally, we can use the same wrapper for all emailed content, leaving it to the consumer to adjust anything specific to the use case. This is a safer way to use the same styles to maintain behavior, and each 'component' (e.g. post header) should handle its own, compartmentalized behavior to not disrupt the whole.

Transactional emails like the magic link do not use this currently, though it could be brought into this as we add further email customization options.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 19, 2026

Walkthrough

This pull request extracts shared email CSS and the HTML wrapper into Handlebars partials. It adds base-styles.hbs (shared email CSS) and email-wrapper.hbs (document/head/body and header rendering), updates template composition to use {{>baseStyles}} and {{#> emailWrapper}}...{{/emailWrapper}}, and registers these partials in the email renderers. Existing templates (styles.hbs, template.hbs, member-welcome wrapper) were refactored to remove duplicate inline styles and document structure and now delegate those concerns to the new partials.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically summarizes the main change: unifying email wrapper templates used for welcome and newsletter emails, which is reflected throughout the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description check ✅ Passed The pull request description is directly related to the changeset, explaining the consolidation of email wrappers for member welcome and newsletter emails into a unified wrapper template.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch unify-wrapper-emails
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
ghost/core/core/server/services/email-rendering/partials/email-wrapper.hbs (1)

40-46: Consider adding alt attribute for header image accessibility.

The header image <img> tag lacks an alt attribute. While this may be decorative, adding a meaningful alt (or empty alt for decorative images) improves email accessibility.

♻️ Suggested improvement
                                                    <a href="{{site.url}}">
                                                        <img
                                                            src="{{headerImage}}"
                                                            {{`#if` headerImageWidth}}
                                                                width="{{headerImageWidth}}"
                                                            {{/if}}
+                                                           alt="{{site.title}}"
                                                        >
                                                    </a>
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@ghost/core/core/server/services/email-rendering/partials/email-wrapper.hbs`
around lines 40 - 46, The <img> tag rendering the header image (using the
headerImage and optional headerImageWidth) is missing an alt attribute; update
the email-wrapper.hbs partial so the image includes an alt attribute, e.g.
alt="{{headerImageAlt}}" and fall back to an empty alt (alt="") when no
descriptive text is provided so decorative images remain accessible; ensure you
reference the existing variables (headerImage, headerImageWidth, headerImageAlt)
and keep the fallback behavior consistent with how other image fields are
handled.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@ghost/core/core/server/services/email-rendering/partials/email-wrapper.hbs`:
- Around line 40-46: The <img> tag rendering the header image (using the
headerImage and optional headerImageWidth) is missing an alt attribute; update
the email-wrapper.hbs partial so the image includes an alt attribute, e.g.
alt="{{headerImageAlt}}" and fall back to an empty alt (alt="") when no
descriptive text is provided so decorative images remain accessible; ensure you
reference the existing variables (headerImage, headerImageWidth, headerImageAlt)
and keep the fallback behavior consistent with how other image fields are
handled.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: dd0f2ce9-b0dc-4f1f-9184-110d77373466

📥 Commits

Reviewing files that changed from the base of the PR and between fd06558 and f2515d9.

📒 Files selected for processing (7)
  • ghost/core/core/server/services/email-rendering/partials/base-styles.hbs
  • ghost/core/core/server/services/email-rendering/partials/email-wrapper.hbs
  • ghost/core/core/server/services/email-service/email-renderer.js
  • ghost/core/core/server/services/email-service/email-templates/partials/styles.hbs
  • ghost/core/core/server/services/email-service/email-templates/template.hbs
  • ghost/core/core/server/services/member-welcome-emails/email-templates/wrapper.hbs
  • ghost/core/core/server/services/member-welcome-emails/member-welcome-email-renderer.js

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.

1 participant