feat: add --react-email-props support for prop-driven templates#232
Draft
bukinoshita wants to merge 1 commit intomainfrom
Draft
feat: add --react-email-props support for prop-driven templates#232bukinoshita wants to merge 1 commit intomainfrom
bukinoshita wants to merge 1 commit intomainfrom
Conversation
The React Email rendering pipeline previously hardcoded an empty props
object when instantiating components, causing prop-driven templates to
either render blank content or throw at render time.
Changes:
- renderReactEmail now accepts an optional props parameter and forwards
it to reactEmailCreateReactElement instead of hardcoding {}
- buildReactEmailHtml accepts an optional props parameter and threads
it through to renderReactEmail
- New parseReactEmailProps utility parses props from --react-email-props
(inline JSON) or --react-email-props-file (JSON file path)
- All 6 commands that support --react-email now also accept
--react-email-props and --react-email-props-file:
emails send, emails batch, templates create, templates update,
broadcasts create, broadcasts update
- Added validation: props flags require --react-email, and the two
props flags are mutually exclusive
- Added tests for parseReactEmailProps and prop forwarding in commands
Resolves BU-611
Co-authored-by: Bu Kinoshita <bukinoshita@users.noreply.github.com>
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 by cubic
Enables prop-driven React Email templates by passing props through the renderer and adding CLI flags to supply them. Fixes BU-611 where templates rendered with empty props, causing missing content or crashes.
New Features
renderReactEmail(cjsPath, props?)andbuildReactEmailHtml(path, opts, props?)now accept a props object and forward it to the component.--react-email-props <json>and--react-email-props-file <path>flags on:emails send,emails batch,templates create,templates update,broadcasts create,broadcasts update.parseReactEmailPropsto parse/validate inline JSON or file-based props.Bug Fixes
{}in the React Email rendering pipeline; props are now correctly passed to components.--react-email, are mutually exclusive, and must parse to a JSON object (not array/null/primitive).Written for commit ea86911. Summary will update on new commits.