Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
helper-date
Advanced tools
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 registere
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.
With Handlebars:
{{date "5 years ago" "YYYY"}}
//=> 2010
With Lo-Dash or Underscore:
<%= date("5 years ago", "YYYY") %>
//=> 2010
With Verb (lo-dash, with special delimiters to avoid delimiter collision in markdown docs):
{%= date('5 years ago', 'YYYY') %}
//=> 2010
npm i helper-date --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('date', require('helper-date'));
To register the helper for use with assemble v0.6.x:
assemble.helper('date', require('helper-date'));
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('./'));
});
var handlebars = require('handlebars');
handlebars.registerHelper('date', require('helper-date'));
Usage
{{date "5 years ago" "YYYY"}}
// as a mixin
_.mixin({date: dateHelper});
_.template('<%= _.date("5 years ago", "YYYY") %>', {});
//=> 'AAA\nBBB\nCCC'
// passed on the context
_.template('<%= date("5 years ago", "YYYY") %>', {date: dateHelper});
//=> 'AAA\nBBB\nCCC'
// as an import
var settings = {imports: {date: dateHelper}};
_.template('<%= date("5 years ago", "YYYY") %>', {}, settings);
//=> 'AAA\nBBB\nCCC'
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
.
FAQs
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 registere
The npm package helper-date receives a total of 100,710 weekly downloads. As such, helper-date popularity was classified as popular.
We found that helper-date demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.