/pinky

A python port of Zurb's Inky email Html template system

Primary LanguagePythonMIT LicenseMIT

Pinky

Inky is an HTML-based templating language that converts simple HTML into complex, responsive email-ready HTML. Designed for Foundation for Emails, a responsive email framework from ZURB.

Inky is built for node, Pinky is just a python port for this great library.

Give Inky simple HTML like this:

<row>
  <columns large="6"></columns>
  <columns large="6"></columns>
</row>

And get complicated, but battle-tested, email-ready HTML like this:

<table class="row">
  <tbody>
    <tr>
      <th class="small-12 large-6 columns first">
        <table>
          <tr>
            <th class="expander"></th>
          </tr>
        </table>
      </th>
      <th class="small-12 large-6 columns first">
        <table>
          <tr>
            <th class="expander"></th>
          </tr>
        </table>
      </th>
    </tr>
  </tbody>
</table>

Installation

Git clone this repo and then install with pip locally

git clone https://github.com/onel/pinky.git
pip install ./pinky

COMING SOON: pip package

Usage

Pinky can be used programatically or from the command line

Programmatic Use

from pinky import Pinky

html_string = '<html>...</html>'
result = Pinky.parse(html_string)

Command Line

pinky "[html string]"

The command returns the resulted HTML string.

Under the hood

Pinky uses BeautifulSoop4 (with the lxml option) to parse the received html string and then replace all the custom Inky tags with the proper html elements (table, tr, td, etc.).

In the second step is uses Premailer to inline the CSS and minify the HTML.