Template helper for formatting dates with moment.js. Works with Handlebars, Lo-Dash or any template engine that supports helper functions.
Install with npm
npm i helper-moment --save
npm test
This should work with any engine, here are a few examples
Register the helper for use with any template engine
template.helper('moment', require('helper-moment'));
To register the helper for use with assemble v0.6.x:
assemble.helper('moment', require('helper-moment'));
Register the helper for use with verb:
var verb = require('verb');
verb.helper('moment', require('helper-moment'));
verb.task('default', function() {
verb.src('.verb*.md')
.pipe(verb.dest('./'));
});
var handlebars = require('handlebars');
handlebars.registerHelper('moment', require('helper-moment'));
// as a mixin
_.mixin({moment: momentHelper});
_.template('<%= _.moment("YYYY") %>', {});
//=> '2015'
// passed on the context
_.template('<%= moment("YYYY") %>', {moment: momentHelper});
//=> '2015'
// as an import
var settings = {imports: {moment: momentHelper}};
_.template('<%= moment("YYYY") %>', {}, settings);
//=> '2015'
With Handlebars:
With Lo-Dash or Underscore:
<%= moment("YYYY") %>
//=> 2015
With Verb (lo-dash, with special delimiters to avoid delimiter collision in markdown docs):
{%= moment('2015') %}
//=> 2015
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue
To request or contribute a helper to the github.com/helpers org, please read this contributing guide to get started.
Jon Schlinkert
Copyright (c) 2014 Jon Schlinkert
Released under the MIT license
This file was generated by verb on December 06, 2014. To update, run npm i -g verb && verb
.