Mustacher
Designed for fit my own needs to build HTML static pages to be incorpored inside a website based on Magento, eZPublish or Drupal templates
It provide an easy way to include handlebar's partials files inside HTML template page with a minimal list of helpers like include, repeat (loop), or, and, livereload...
Install
npm install mustacher --save
Exposed helpers
inline
blocks
Examples
const fs = ;const path = ;const mustacher = ; // variables at root level touched by any helperconst context = private: 'as @root.private' ; // default configconst config = cwd: __dirname delimiter: ldim: '{{' rdim: '}}' partials: ext: '.hbs' src: 'partials' ; const templateFile = path;const outputfile = path; const fsOptions = encoding: 'utf8' ;const templateContent = fs;const compiledOutput = ;fs;
inline
$include
{{$include 'relative/to/root/path/to/template'}}
$css & $js helper
... {{$css 'path/to/css/file'}} <!-- include inline --> {{$css '__build__/path/to/css/file' true}} ...
... {{$js 'path/to/js/file'}}
$image (default width: 300)
{{$image}}
{{$image 300}}
{{$image 300 200}}
$timestamp
$livereload
{{$livereload 1337}}
$random
{{$random 1 31}} Juanary 1970
{{$random 0 1 true}}
literal
$ldim
{{$ldim}}toto {{$ldim}}toto{{$rdim}}
$rdim
toto{{$rdim}} {{$ldim}}toto{{$rdim}}
$css
{{$css 'path/to/file'}} {{$css 'path/to/file.min'}} {{$css 'path/to/file.min''{"media":"print,projection,screen"}'}}
$js
{{$js 'path/to/file'}} {{$js 'path/to/file.min'}} {{$js 'path/to/file.min''{"data-main":"main.js"}'}}
blocks
#repeat
{{#repeat 4}} item {{#repeat}} sub item {{@../index}}/{{@index}} {{/repeat}} {{/repeat}}
#and
{{#and true false ...}}fail{{else}}success{{/and}}
#or
{{#or true false ...}}success{{else}}fail{{/or}}
#equal
{{#equal 'toto' 'blague'}}fail{{else}}success{{/equal}}
Issues
not yet implemented
- Lorem Ipsum