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
npm test
This should work with any engine, here are a few examples
Register the helper for use with any template engine
template.helper('year', require('helper-year'));
To register the helper for use with assemble v0.6.x:
assemble.helper('year', require('helper-year'));
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('./'));
});
var handlebars = require('handlebars');
handlebars.registerHelper('year', require('helper-year'));
// 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
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 01, 2014.