helper-date

WebJar for helper-date

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

helper-date
Last Version

Last Version

1.0.1
Release Date

Release Date

Type

Type

jar
Description

Description

helper-date
WebJar for helper-date
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/helpers/helper-date

Download helper-date

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/helper-date/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>helper-date</artifactId>
    <version>1.0.1</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/helper-date/
implementation 'org.webjars.npm:helper-date:1.0.1'
// https://jarcasting.com/artifacts/org.webjars.npm/helper-date/
implementation ("org.webjars.npm:helper-date:1.0.1")
'org.webjars.npm:helper-date:jar:1.0.1'
<dependency org="org.webjars.npm" name="helper-date" rev="1.0.1">
  <artifact name="helper-date" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='helper-date', version='1.0.1')
)
libraryDependencies += "org.webjars.npm" % "helper-date" % "1.0.1"
[org.webjars.npm/helper-date "1.0.1"]

Dependencies

compile (3)

Group / Artifact Type Version
org.webjars.npm : date.js jar [0.3.1,0.4)
org.webjars.npm : handlebars-utils jar [1.0.4,2)
org.webjars.npm : moment jar [2.18.1,3)

Project Modules

There are no modules declared in this project.

helper-date NPM version NPM monthly downloads NPM total downloads Linux Build Status

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.

Follow this project's author, Jon Schlinkert, for updates on this project and others.

Install

Install with npm:

$ npm install --save helper-date

Usage

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):

2012
//=> 2010

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.0 and greater:

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"}}

lodash 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);
//=> 2010

About

Related projects

You might also be interested in these projects:

Contributing

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

Please read the contributing guide for advice on opening issues, pull requests, and coding standards.

Contributors

Commits Contributor
20 jonschlinkert
1 bradtaylorsf

Building docs

(This project's readme.md is generated by verb, please don't edit the readme directly. Any changes to the readme must be made in the .verb.md readme template.)

To generate the readme, run the following command:

$ npm install -g verbose/verb#dev verb-generate-readme && verb

Running tests

Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:

$ npm install && npm test

Author

Jon Schlinkert

License

Copyright © 2017, Jon Schlinkert. Released under the MIT License.


This file was generated by verb-generate-readme, v0.6.0, on September 04, 2017.

org.webjars.npm

Helpers

Template helpers and utils for any engine. Create an issue on helpers/meta to request a new helper repo, or ask to be added to the org.

Versions

Version
1.0.1