ActiveCampaign / postmark-cli

The official CLI tool for Postmark
https://postmarkapp.com
MIT License
79 stars 9 forks source link

Template preview command #11

Closed derekrushforth closed 4 years ago

derekrushforth commented 5 years ago

Hey @atheken @ibalosh @matt-west @rianvdm,

Now that we've introduced layouts, it's impossible to see how your templates look when using the CLI tool. Templates look broken since the outer content and CSS are typically stored in the layout:

sad template

I put together a proof of concept that lets users preview their templates in the browser using a command. This works similarly to the Mailer Previews in Rails.

postmark templates preview ~/Desktop/your-templates

Options:
  --port, -p  The port to open up the preview server on        [number] [default: 3005]

This basically whips up a local express server that the user can navigate to in their browser. I put together a simple interface for previewing everything:

Preview-index Preview-template-html

This doesn't rely on any external services or anything. I was able to combine the template and layout with some regex. Everything in the interface is based on each template's meta.json file and content files. So this means changing a template's LayoutTemplate will reflect in the preview when the page is refreshed.

We don't have anything fancy like hot reloading or anything. My goal is to keep it simple for the first release. Before I take this any further, can you think of anything that I'm missing or that would be helpful in a future release? Is this feature worth adding to the CLI tool?

PS. The code still needs refactoring and the interface needs polishing. I'm not looking for feedback there yet.

Thanks!

matt-west commented 5 years ago

This is awesome!

A toggle to test the styles in dark mode might be handy (if it’s possible to spoof that in the browser), but it’s definitely not essential for an initial release of this.

ibalosh commented 5 years ago

Love it!

rianvdm commented 5 years ago

This looks great 👍

atheken commented 4 years ago

This is great, @derekrushforth - my only suggestion is that you throttle/debounce file change events so that reloads are not as aggressive. Otherwise, this is an awesome improvement to the tool and I think users are going to love it.

derekrushforth commented 4 years ago

Thanks @atheken! I'm excited to get this out there. I've also added debouncing to the file change events.