npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@knopkem/bootstrap-email

v1.2.11

Published

Convert a bootstrap-like template into email-compatible table layout

Downloads

21

Readme

NPM

Based on the original Bootstrap Email by stuyam, this library allows you to compile a regular HTML markdown with usual Bootstrap classes into cringy table-based email-layouts ... with JAVASCRIPT 🎉🎊✨.

Table of contents

Supported Bootstrap Classes

{color} in these examples is primary, secondary, success, warning, danger, light, and dark

  • Alerts: .alert, .alert-{color}
  • Badges: .badge, .badge-{color}, .badge-pill
  • Buttons: .btn, .btn-{color}, .btn-outline-{color}
  • Cards: .card, .card-body
  • Color: .text-{color}, .bg-{color}
  • Containers: .container, .container-fluid
  • Floats: .float-left, .float-right
  • Grid: .row, .col-{1-12}, .col-lg-{1-12}
  • Hrs: <hr>
  • Spacing: .p{tlbrxy}-{lg-}{0-5}, .m{tby}-{lg-}{0-5}, mx-auto
  • Width: w-{lg-}{25,50,75,100}
  • Tables: .table, .table-striped,.table-bordered, .thead-light, .thead-dark, .table-{color}, .table-dark
  • Typography: <h1>, <h2>, <h3>, <h4>, <h5>, <h6>, <strong>, <u>, <em>, <s>, .text-{sm|lg-}left, .text-{sm|lg-}center, .text-{sm|lg-}right, .display-{1-4}, .lead, .small

Additional Classes

Installation and usage

Install package with npm i bootstrap-email -S

To compile a default template:

const BootstrapEmail = require('bootstrap-email');

const template = new BootstrapEmail('<absolute-path-to-template>.html');

// const template = new BootstrapEmail([
//     '<absolute-path-to-first-template>.html',
//     '<absolute-path-to-second-template>.html',
// ]);
//
// const template = new BootstrapEmail('<div class="container">...</div>'); 

template.compileAndSave('<absolute-path-to-output>.html');

Alternatively use the Gulp plugin to integrate Bootstrap Email into your templating workflow.

Options

  • style string (optional) - Path to css or scss file, which should be inlined. Default is bootstrap-email.scss
  • head string (optional) - Path to css or scss file, which should be injected to head. Default is head.scss
  • templates array<string> - Array with paths to html files you want to compile.
  • logLevel

Methods

new BootstrapEmail(templates, options)
compile(): string | [{path: string, document: string}]

Performs a full compile and returns compiled document(s).

If only one template is about to compile, returns the compiled template, otherwise an array containing objects with the path of the input-file and the compiled document.

const singleTemplate = new BootstrapEmail('<absolute-path-to-template>.html');

// returns string
singleTemplate.compile();


const multipleTemplates = new BootstrapEmail(['<absolute-path>', ...]);

// returns [{path:'<absolute-path-to-source>', document: '...'}, ...]
multipleTemplates.compile();
compileAndSave(path): void

Performs a full compile and saves compiled files into given path.

If only one template is given, pass a full path including filename and extension. Otherwise pass only a directory name. The filenames will be used from the source files.

const singleTemplate = new BootstrapEmail('<absolute-path-to-template>.html');
singleTemplate.compileAndSave('<absolute-out-compiled>.html');


const multipleTemplates = new BootstrapEmail(['<absolute-path>', ...]);
multipleTemplates.compileAndSave('<absolute-out>');

Todos

  • [ ] Support multiple CSS/SASS-files
  • [ ] Add Typescript typings
  • [ ] Implement bootstrap-like vertical align classes
  • [ ] Extract automatically CSS that cannot be inlined (:hover, :focus, ...)
  • [ ] Add option for output formatting (minimized, formatted, ...)
  • [ ] Write better docs & examples
  • [ ] Write cli script

Known Bugs

  • Outlook 2013 on Windows 10 with 120DPI can't scale images properly
  • Paddings don't work properly on Outlook (Windows ofc)
  • Auto-sized tables behave as if they would have width="100%" on Outlook 2003 (Windows ofc)
  • Outlook 2003 (Windows) is fucked up in general