feat: add external template rendering with configurable branding#18
Merged
juliankoehn merged 11 commits intomainfrom Mar 29, 2026
Merged
feat: add external template rendering with configurable branding#18juliankoehn merged 11 commits intomainfrom
juliankoehn merged 11 commits intomainfrom
Conversation
Design spec for extending comms with externally-provided templates and configurable branding. Two-phase API (RenderTemplate + SendRendered), Go html/template shell with table layout, TDD plan in 8 phases.
10-task TDD implementation plan for external template rendering with branding support. Tests-first approach, bite-sized steps, complete code in every step.
Introduces the Branding struct and resolveBranding helper as the foundational building block for external template rendering with per-tenant branding support.
Introduces emailShellTemplate (shell.go) with table-based layout for broad email client compatibility, and renderShell/shellData in render_external.go to wrap pre-rendered body HTML with a branded header, preheader, and footer. 11 TDD tests added.
Implements the RenderTemplate function that orchestrates validation, branding resolution, data merging, and subject/body/text rendering into a ready-to-send RenderedEmail. Partial failures (one of body or text) are tolerated; only errors when both renderers fail.
Implements SendRendered for sending pre-rendered emails and SendFromTemplate as a convenience wrapper combining RenderTemplate + SendRendered in one call.
When no TextTemplate is provided but BodyTemplate renders successfully, automatically generate a plain text version by stripping HTML tags, converting block elements to newlines, and decoding HTML entities. Explicit TextTemplate always takes precedence over the fallback.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
RenderTemplate()renders Go template strings into a branded HTML email shell (pure function, no driver needed)SendRendered()andSendFromTemplate()send rendered emails via the configured driverTextTemplateis providedSend*methods are completely unchanged — this is a purely additive extensionNew Public API
ExternalTemplateBrandingRenderedEmailRenderTemplate()RenderedEmailSendRendered()Comms: sends a pre-rendered emailSendFromTemplate()Comms: convenience render + send in one callTest plan
-race