Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
roman-yerin opened this issue Sep 1, 2024 · 3 comments

Comments

@roman-yerin
Copy link

  • Maizzle Version: 5.0.0-beta.24

Please update types.

@cossssmin
Copy link
Member

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

@roman-yerin
Copy link
Author

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
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants