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

bm-email-templatizer

v1.8.0

Published

create email templates through jade/pug, sass, and locale json files

Downloads

16

Readme

#bmEmailTemplatizer An email template engine that truely works.

  • compile multiple emails templates with multiple locales.
  • fully customizable pipeline.
  • i18n and customizable locals
  • consolidate.js for view engine.

##Usage ###Minimal

var bmEmailTemplatizer = require('bm-email-templatizer');

bmEmailTemplatizer
  .allLocalesAllFiles()
  .then(function(results) {
    console.log('results', results);
  })
  .catch(function(err) {
    console.log('error', err);
  });

##API ###setOptions parameters: options object returns: bmEmailTemplatizer

###allLocalesAllFiles parameters: none. returns: Promise. resolves: pipeline resolves.

#Options

| Option | Type | Description | | ------------------- | :------: | -------------------------------------------: | | pipeline | Array | list of functions to be run by templatizer. | | paths | Object | See Paths section. | | consolidate | Object | See Consolidate section. | | i18nConfigurations | Object | See i18n configurations section. |

var defaulOptions = {
  pipeline: ['compilePug', 'compileSass', 'juiceStyles', 'writeHtml'],
  paths: {
    base: process.cwd(),
    scss: 'scss/index.scss',
    locales: 'locales/',
    views: 'views/**/*.pug',
    compiled: 'compiled'
  },
  consolidate: {
    viewEngine: 'pug',
    locals: {},
    options: {}
  }
}

Consolidate

consolidate.js is used to support a HUGE list of view engines!

Supported template engines by consolidate:

consolidate.locals

Default: {}

view engine locals, can be used to add custom functions to be used while rendering the view. example(rendering handlebar templates through jade):

consolidate: {
  locals: {
    _raw: function(variableName) {
      return String.raw`${variableName}`;
    }
  }
}
//- jade view
html
  body
    div
      | #{ _raw("{{#if user_name}}") }
      div=__('welcome-message')
      | #{ _raw("{{/if}}") }

node-i18n is automatically embedded to the view engine.

consolidate.viewEngine

Default: pug view engine, check

consolidate.options

Default: {} options sent to view engine

Paths

###paths.base Default: process.cwd()

base path of project. By default it is the current working directory, the directory path node is called from.

###paths.scss Default: scss/index.scss

Entrance point for scss file. Currently accepts only one entrance point.

###paths.views Default: views/**/*.pug

path.views accept a glob pattern (relative or absolute).

###paths.locales Default: locales/

path.locales accept a directory path (relative or absolute).

locales Locale file name will be supplied as a directory name to the writeHTML pipeline command

###paths.compiled Default: compiled

Accepts a string for a folder name relative to the base path. Used by writeHtml in the pipeline to write the compiled files into directory. `{base}/{compiled}/{locale}/{fileName}.html

| Future: accepts an object, with absolute boolean, ext name, and folder path.

##Scss To get the active locale in the scss files, use getActiveLocale();

example:

// index.scss
$language: getActiveLocale();
$direction: if($language == 'ar', rtl, ltr);

html {
  direction: $direction;
}

@if $language == 'du' {
  .test-class {
    color: blue;
  }
}

##i18n config config options passed to node-i18n, check here

if i18nConfig.locales is not passed, they are predicted based on json files in the paths.locales directory.

i18nConfig.directory and i18nConfig.register properties are ignored.