hmpo-template-mixins
Advanced tools
Comparing version 0.1.8 to 0.1.9
@@ -263,4 +263,5 @@ 'use strict'; | ||
return function (txt) { | ||
var value = Hogan.compile(txt).render(this); | ||
return moment(value).format('D MMMM YYYY'); | ||
txt = (txt || '').split('|'); | ||
var value = Hogan.compile(txt[0]).render(this); | ||
return moment(value).format(txt[1] || 'D MMMM YYYY'); | ||
}; | ||
@@ -267,0 +268,0 @@ }; |
{ | ||
"name": "hmpo-template-mixins", | ||
"version": "0.1.8", | ||
"version": "0.1.9", | ||
"description": "A middleware that exposes a series of Mustache mixins on res.locals to ease usage of forms, translations, and some general needs.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -199,2 +199,30 @@ var mixins = require('../lib/template-mixins'); | ||
describe('date', function () { | ||
beforeEach(function () { | ||
middleware = mixins(translate, {}); | ||
}); | ||
it('adds a function to res.locals', function () { | ||
middleware(req, res, next); | ||
res.locals['date'].should.be.a('function'); | ||
}); | ||
it('returns a function', function () { | ||
middleware(req, res, next); | ||
res.locals['date']().should.be.a('function'); | ||
}); | ||
it('formats a date', function () { | ||
middleware(req, res, next); | ||
res.locals['date']().call(res.locals, '2015-03-26').should.equal('26 March 2015'); | ||
}); | ||
it('applys a date format if specified', function () { | ||
middleware(req, res, next); | ||
res.locals['date']().call(res.locals, '2015-03|MMMM YYYY').should.equal('March 2015'); | ||
}); | ||
}); | ||
}); |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
26317
473
0