Founding Director at Detroit Technical English·
HTML Templates: a Pain in the Backend

We chose Pug because writing raw HTML is about as enjoyable as a fart in a spacesuit, and writing decently-rendering HTML for enterprise email clients is a soul-sucking type of black magic.

Pug takes HTML as a (...markdown) language out of the stack by using a simple, sane syntax to represent HTML in just JavaScript©. Piecing together what you need from any number of standalone - including functional - components is both delightfully easy, and easy to maintain.

All you're really writing are exportable JavaScript functions that take a single Object parameter - once that concept takes hold, you'll quickly swear off angle brackets in favor of neatly indented and extensible e-mail, invoice, and reporting templates.

There's a jstransformer filter for instant interop with just about every preprocessor ( Stylus , in our case) and file format out there. Pass that compiled HTML though Juice on Node.js and bam - rugged HTML-emails that hold up in even the wonkiest Lotus Notes clients.

That the end result is 'just HTML' is the final cherry on top. Debugging needs only DevTools, and Puppeteer 's now all you need to create fancy-pants PDFs to your heart's content.

READ LESS
7 upvotes·216.2K views
Avatar of Dave Willenberg

Dave Willenberg

Founding Director at Detroit Technical English