1.8.0 • Published 8 years ago

bm-email-templatizer v1.8.0

Weekly downloads
3
License
MIT
Repository
github
Last release
8 years ago

#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.

1.8.0

8 years ago

1.7.9

8 years ago

1.7.8

8 years ago

1.6.7

8 years ago

1.6.6

8 years ago

1.6.5

8 years ago

1.6.4

8 years ago

1.6.3

8 years ago

1.6.2

8 years ago

1.6.1

8 years ago

1.6.0

8 years ago

1.5.7

8 years ago

1.5.5

8 years ago

1.5.4

8 years ago

1.5.3

8 years ago

1.5.2

8 years ago

1.5.1

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago