hmpo-template-mixins
Advanced tools
@@ -69,2 +69,12 @@ 'use strict'; | ||
function classnames(key) { | ||
if (fields[key]) { | ||
if (_.isArray(fields[key].className)) { | ||
return fields[key].className.join(' '); | ||
} else { | ||
return fields[key].className; | ||
} | ||
} | ||
} | ||
function inputText(key, extension) { | ||
@@ -74,2 +84,3 @@ extension = extension || {}; | ||
id: key, | ||
className: extension.className || classnames(key), | ||
type: extension.type || type(key), | ||
@@ -76,0 +87,0 @@ value: this.values && this.values[key], |
{ | ||
"name": "hmpo-template-mixins", | ||
"version": "0.1.10", | ||
"version": "0.1.11", | ||
"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", |
@@ -77,2 +77,15 @@ var mixins = require('../lib/template-mixins'); | ||
it('should have classes if one or more were specified against the field', function () { | ||
middleware = mixins(translate, { | ||
'field-name': { | ||
'className': ['abc', 'def'] | ||
} | ||
}); | ||
middleware(req, res, next); | ||
res.locals['input-text']().call(res.locals, 'field-name'); | ||
render.should.have.been.calledWith(sinon.match({ | ||
className: 'abc def' | ||
})); | ||
}); | ||
}); | ||
@@ -79,0 +92,0 @@ |
Sorry, the diff of this file is not supported yet
29031
3.13%522
4.4%