Socket
Socket
Sign inDemoInstall

bm-email-templatizer

Package Overview
Dependencies
292
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    bm-email-templatizer

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


Version published
Weekly downloads
21
increased by5%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

#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

OptionTypeDescription
pipelineArraylist of functions to be run by templatizer.
pathsObjectSee Paths section.
consolidateObjectSee Consolidate section.
i18nConfigurationsObjectSee 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.

Keywords

FAQs

Last updated on 12 Jul 2016

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc