maizzle / framework

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

Pushing to postmark and using template functions like loops #416

Closed viperfx closed 3 years ago

viperfx commented 3 years ago

I would really like to use this framework to develop postmark emails, however, it does not fit with existing tools.

For example, there is postmark cli (official) - https://github.com/wildbit/postmark-cli/ that allows for live preview and development of postmark templates. So it's easy to pull the templates from postmark, make changes and push them again (because the structure also setups the metadata).

It also renders loops using the https://github.com/wildbit/mustachio template library.

Is there a workflow I can adopt to making the workflow for transactional templates with dynamic variables a bit easier?

cossssmin commented 3 years ago

So it's easy to pull the templates from postmark, make changes and push them again

Local development in Maizzle works with files you have on disk.

So if they offer an API, you may be able to connect to the Postmark API in your config.js inside the beforeCreate event, fetch templates, and (over?)write them on disk inside the src/templates/ folder. This way maizzle serve should work (haven't tested).

Then, maybe in config.production.js, you could hook into the afterTransformers or afterBuild events and push the edited templates that have been compiled to HTML inside the build_production foder, back to Postmark.

This is just a high level overview, you'd need to connect to the API and write all the code to fetch from there yourself. Things might get even more complicated if you need to populate certain variables with data coming from Postmark...