shellscape / jsx-email

Build emails with a delightful DX
https://jsx.email
MIT License
897 stars 28 forks source link

Pass custom props to the `email build` command #96

Closed semanser closed 6 months ago

semanser commented 6 months ago

Feature Use Case

I want to use jsx-email with Golang, and in order to do that, I need to render the emails to HTML first and then import them as strings/files in my Golang app. My email templates have some custom properties that I want to set dynamically while building the HTML files.

This should potentially allow the use of templates created by JSX-email with almost any programming language.

Feature Proposal

Let's say we have this template:

import { Button } from 'jsx-email';

const Email = ({ title }) => {
  return (
    <Button href="https://example.com" style={{ color: '#61dafb', padding: '10px 20px' }}>
      {title}
    </Button>
  );
};

I want to be able to do something like this:

email build ./email.tsx --title="Click me"

Being able to pass custom props to the CLI tool allows to generate emails programmatically in any language that supports spawning new CLI processes.

shellscape commented 6 months ago

Hey thanks for the issue. This is already possible with the --props flag, which accepts JSON. Run email help build for a full list of flags for that command.

semanser commented 6 months ago

Nice, thanks!