Launch Week Day 1:Rust Support in Socket Is Now Generally Available.Learn More
Socket
Book a DemoInstallSign in
Socket

helper-year

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

helper-year

Template helper for adding the current year. Good for adding dates for licenses, copyrights, last modified date, comment dates, etc. Works with handlebars, lo-dash or any template engine that has support for helper functions.

latest
Source
npmnpm
Version
0.1.0
Version published
Maintainers
1
Created
Source

helper-year NPM version

Template helper for adding the current year. Good for adding dates for licenses, copyrights, last modified date, comment dates, etc. Works with handlebars, lo-dash or any template engine that has support for helper functions.

Install with npm

npm i helper-year --save

Examples

{%= year() %}
//=> 2014
{%= year("YYYY") %}
//=> 2014
{%= year("YY") %}
//=> 14

Run tests

npm test

Register 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('year', require('helper-year'));

assemble

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

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

verb

Register the helper for use with verb:

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

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

handlebars

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

Lo-Dash or underscore

// as a mixin
_.mixin({year: require('helper-year')});
_.template('<%= _.year() %>', {});
//=> 2014

// passed on the context
_.template('<%= year() %>', {year: require('helper-year')});
//=> 2014

// as an import
var settings = {imports: {year: require('helper-year')}};
_.template('<%= year() %>', {}, settings);
//=> 2014

Contributing

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) 2014 Jon Schlinkert
Released under the MIT license

This file was generated by verb on December 01, 2014.

Keywords

date

FAQs

Package last updated on 01 Dec 2014

Did you know?

Socket

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.

Install

Related posts