New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

hmpo-template-mixins

Package Overview
Dependencies
Maintainers
3
Versions
81
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hmpo-template-mixins - npm Package Compare versions

Comparing version 0.5.0 to 0.6.0

partials/forms/textarea-group.html

9

lib/template-mixins.js

@@ -41,3 +41,4 @@ 'use strict';

'partials/forms/select',
'partials/forms/checkbox'
'partials/forms/checkbox',
'partials/forms/textarea-group'
];

@@ -209,2 +210,8 @@ var compiled = _.chain(PARTIALS).map(function (relativeTemplatePath) {

res.locals.textarea = function () {
return function (key) {
return compiled['partials/forms/textarea-group'].render(inputText.call(this, key));
};
};
res.locals['radio-group'] = function () {

@@ -211,0 +218,0 @@ return function (key) {

2

package.json
{
"name": "hmpo-template-mixins",
"version": "0.5.0",
"version": "0.6.0",
"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",

@@ -54,2 +54,3 @@ # passports-template-mixins

input-submit
textarea
```

@@ -245,2 +245,78 @@ var mixins = require('../lib/template-mixins');

describe('textarea', function () {
beforeEach(function () {
middleware = mixins(translate, {});
});
it('adds a function to res.locals', function () {
middleware(req, res, next);
res.locals.textarea.should.be.a('function');
});
it('returns a function', function () {
middleware(req, res, next);
res.locals.textarea().should.be.a('function');
});
it('looks up field label', function () {
middleware(req, res, next);
res.locals.textarea().call(res.locals, 'field-name');
render.should.have.been.calledWith(sinon.match({
label: 'fields.field-name.label'
}));
});
it('prefixes translation lookup with namespace if provided', function () {
middleware = mixins(translate, {}, { sharedTranslationsKey: 'name.space' });
middleware(req, res, next);
res.locals.textarea().call(res.locals, 'field-name');
render.should.have.been.calledWith(sinon.match({
label: 'name.space.fields.field-name.label'
}));
});
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.textarea().call(res.locals, 'field-name');
render.should.have.been.calledWith(sinon.match({
className: 'abc def'
}));
});
it('uses maxlength property set at a field level over default option', function () {
middleware = mixins(translate, {
'field-name': {
'validate': [
{ type: 'maxlength', arguments: 10 }
]
}
});
middleware(req, res, next);
res.locals.textarea().call(res.locals, 'field-name');
render.should.have.been.calledWith(sinon.match({
maxlength: 10
}));
});
it('uses locales translation property', function () {
middleware = mixins(sinon.stub().withArgs({'label': 'field-name.label'}).returns('Field name'), {
'field-name': {
'label': 'field-name.label'
}
});
middleware(req, res, next);
res.locals.textarea().call(res.locals, 'field-name');
render.should.have.been.calledWith(sinon.match({
label: 'Field name'
}));
});
});
describe('checkbox', function () {

@@ -247,0 +323,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc