Giter Site home page Giter Site logo

lukethacoder / gulp-email-template-builder Goto Github PK

View Code? Open in Web Editor NEW
2.0 3.0 0.0 83 KB

๐Ÿญ A small html templating engine built to make building email templates more enjoyable.

License: MIT License

JavaScript 0.92% HTML 98.97% CSS 0.10%
email-template email-template-builder gulp posthtml

gulp-email-template-builder's Introduction

๐Ÿญ Gulp Email Template Builder

A small html templating engine built to make building email templates more enjoyable.

The purpose of this small engine is to "componentise" html blocks and allow you to build reusable HTML components to be used by a suite of email templates.

Under to hood we're using Gulp, PostHTML (with posthtml-include) and BrowserSync.

Any css added to style.css will be pulled inline when compiled

๐Ÿ”ฅ Features

  • HTML Components
  • BrowserSync/Hot Reload
  • CSS Inlining

๐Ÿš€ Getting started

yarn
# or npm i

yarn dev
# or npm run dev

NOTE: make sure you have the Gulp cli installed.

๐Ÿฆ• Example

Included in the src folder is an example setup. All blocks are in a separate folder and are being referenced by the index.html file.

<table width="650" border="0" cellspacing="0" cellpadding="0" class="mobile-shell">
  <tr>
    <td class="td" style="width: 650px; min-width: 650px; font-size: 0pt; line-height: 0pt; padding: 0; margin: 0; font-weight: normal">
      <!-- The include markup is where the magic happens -->
      <include src="blocks/header.html"></include>
      <include src="blocks/feature-one.html"></include>
      <!-- include more blocks here -->
      <include src="blocks/footer.html"></include>
    </td>
  </tr>
</table>

Pass Props to Blocks

To pass props use the locals props on the <include/>, then on the child, use {{ VARIABLE_NAME }}.

<!-- Parent Component -->
<table width="650" border="0" cellspacing="0" cellpadding="0" class="mobile-shell">
  <tr>
    <td class="td" style="width: 650px; min-width: 650px; font-size: 0pt; line-height: 0pt; padding: 0; margin: 0; font-weight: normal">
      <!-- The include markup is where the magic happens -->
      <include src="blocks/header.html"></include>
      <include
        src="blocks/feature-one.html"
        locals='{ "primaryColor": "#1e52bd", "secondaryColor": "#e85711"}'
      ></include>
      <!-- include more blocks here -->
      <include src="blocks/footer.html"></include>
    </td>
  </tr>
</table>

<!-- Child Component -->
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td style="color:{{ primaryColor }};">
      <multiline>Primary Color Goes Here</multiline>
    </td>
  </tr>
  <tr>
    <td style="color:{{ secondaryColor }};">
      <multiline>Secondary Color Goes Here</multiline>
    </td>
  </tr>
</table>

๐Ÿ“ License

Licensed under the MIT License.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.