Package Exports
- helper-date
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (helper-date) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
helper-date 
Format dates with date.js and moment.js. Uses date.js to parse human readable date phrases, and moment to format the rendered output. Should work with any Handlebars, Lo-Dash, underscore, or any template engine that allows helper functions to be registered. Also compatible with verb, assemble and Template.
Examples
With Handlebars:
{{date "5 years ago" "YYYY"}}
//=> 2010With Lo-Dash or Underscore:
<%= date("5 years ago", "YYYY") %>
//=> 2010With Verb (lo-dash, with special delimiters to avoid delimiter collision in markdown docs):
{%= date('5 years ago', 'YYYY') %}
//=> 2010Install with npm
npm i helper-date --saveRun tests
npm testRegister the helper
This should work with any engine, here are a few examples
template
Register the helper for use with any template engine
template.helper('date', require('helper-date'));assemble
To register the helper for use with assemble v0.6.x:
assemble.helper('date', require('helper-date'));verb
Register the helper for use with verb:
var verb = require('verb');
verb.helper('date', require('helper-date'));
verb.task('default', function() {
verb.src('.verb*.md')
.pipe(verb.dest('./'));
});handlebars
var handlebars = require('handlebars');
handlebars.registerHelper('date', require('helper-date'));Usage
{{date "5 years ago" "YYYY"}}Lo-Dash or underscore
// as a mixin
_.mixin({date: dateHelper});
_.template('<%= _.date("5 years ago", "YYYY") %>', {});
//=> 2010
// passed on the context
_.template('<%= date("5 years ago", "YYYY") %>', {date: dateHelper});
//=> 2010
// as an import
var settings = {imports: {date: dateHelper}};
_.template('<%= date("5 years ago", "YYYY") %>', {}, settings);
//=> 2010Contributing
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.
Author
Jon Schlinkert
License
Copyright (c) 2015 Jon Schlinkert
Released under the MIT license
This file was generated by verb on February 17, 2015.