framework icon indicating copy to clipboard operation
framework copied to clipboard

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

Open roman-yerin opened this issue 1 year ago • 3 comments

  • Maizzle Version: 5.0.0-beta.24

Please update types.

roman-yerin avatar Sep 01 '24 10:09 roman-yerin

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

cossssmin avatar Sep 01 '24 12:09 cossssmin

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.

roman-yerin avatar Sep 01 '24 14:09 roman-yerin

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.

cossssmin avatar Sep 02 '24 15:09 cossssmin