JSPM

helper-dateformat

0.1.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 188
  • Score
    100M100P100Q84084F

Template helper for adding formatted dates using node-dateformat. Works with Handlebars, Lo-Dash, underscore, or any template engine that supports helper functions. Also compatible with verb, assemble and Template.

Package Exports

  • helper-dateformat

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-dateformat) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

helper-dateformat NPM version

Template helper for adding formatted dates using node-dateformat. Works with Handlebars, Lo-Dash, underscore, or any template engine that supports helper functions. Also compatible with verb, assemble and Template.

See node-dateformat for all available options.

Install with npm

npm i helper-dateformat --save

Run tests

npm test

Register the helper

This should work with any engine, here some examples

template

Register the helper for use with any template engine

template.helper('dateformat', require('helper-dateformat'));

assemble

To register the helper for use with assemble v0.6.x:

assemble.helper('dateformat', require('helper-dateformat'));

verb

Register the helper for use with verb:

var verb = require('verb');
verb.helper('dateformat', require('helper-dateformat'));

Usage

// doc.md
{%= dateformat("MMMM DD, YYYY") %}

// render

verb.task('default', function() {
  verb.src('doc.md')
    .pipe(verb.dest('./'));
});

handlebars

var handlebars = require('handlebars');
handlebars.registerHelper('dateformat', require('helper-dateformat'));

Usage

{{dateformat "MMMM DD, YYYY"}}

Lo-Dash or underscore

var helper = require('helper-dateformat');

// as a mixin
_.mixin({dateformat: helper});
_.template('<%= dateformat("MMMM DD, YYYY") %>', {});

// passed on the context
_.template('<%= dateformat("MMMM DD, YYYY") %>', {dateformat: helper});

// as an import
var settings = {imports: {dateformat: helper}};
_.template('<%= dateformat("MMMM DD, YYYY") %>', {}, settings);

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue

Author

Jon Schlinkert

License

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.