maizzle / framework

Quickly build HTML emails with Tailwind CSS.
https://maizzle.com
MIT License
1.24k stars 49 forks source link

Type definition propagate "plaintext" while in fact "generatePlaintext" exported #1345

Open roman-yerin opened 2 months ago

roman-yerin commented 2 months ago

Please update types.

cossssmin commented 2 months ago

We could also take the opportunity to rename the function if there's a better/shorter name than generatePlaintext.

roman-yerin commented 2 months ago

First, I'd wanted to thank you for this great lib, I can use to make emails creation a little bit less awful. IMHO, I wonder why do we have two separate calls at all? In most use cases we do need both html and plaintext variants to compose a message, so it would be great to call render once and get both text and html. If it doesn't make sense for some reason, I'd propose to keep one naming style and rename render to html and generatePlaintext to text. And if you don't worry about the backward compatibility, personally me prefer that kind of interface:

const template = fs.readFileSync(template_name)
const maizzle = new Maizzle(config)
const { html, text } = maizzle.Render(template)

This type of interface is more friendly and support re-use of the initialized Maizzle instance instead of producing a new one each time you call render now.

cossssmin commented 2 months ago

You can already do render(html, {plaintext: true}), the plaintext method is for cases where you might need to only generate plaintext and not compile any templates.