Huge News!Announcing our $40M Series B led by Abstract Ventures.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 5.1.0 to 5.2.0

partials/forms/option-group.html

60

lib/template-mixins.js

@@ -53,6 +53,6 @@ 'use strict';

'partials/forms/input-submit',
'partials/forms/radio-group',
'partials/forms/select',
'partials/forms/checkbox',
'partials/forms/textarea-group'
'partials/forms/textarea-group',
'partials/forms/option-group'
];

@@ -106,6 +106,2 @@ var compiled = _.chain(PARTIALS).map(function (relativeTemplatePath) {

var t = function (key) {
return translate(sharedTranslationsKey + key);
};
var hoganRender = function (text, ctx) {

@@ -117,6 +113,10 @@ if (!text) { return ''; }

var t = function (key) {
return hoganRender(translate(sharedTranslationsKey + key));
};
// Like t() but returns null on failed translations
var conditionalTranslate = function (key) {
key = sharedTranslationsKey + key;
var translated = translate(key);
var translated = hoganRender(translate(key));
return translated !== key ? translated : null;

@@ -204,2 +204,3 @@ };

labelClassName: classNames(field, 'labelClassName') || 'form-label-bold',
labelTextClassName: classNames(field, 'labelTextClassName'),
hint: hint,

@@ -235,3 +236,4 @@ hintId: extension.hintId || (hint ? key + '-hint' : null),

function optionGroup(key) {
function optionGroup(key, opts) {
opts = opts || {};
var field = getFieldConfig(this.options.fields, key);

@@ -254,2 +256,3 @@ var legend = field.legend;

legendClassName: legendClassName,
role: opts.type === 'radio' ? 'radiogroup' : 'group',
hint: conditionalTranslate(getTranslationKey(field, key, 'hint')),

@@ -271,3 +274,6 @@ options: _.map(field.options, function (obj) {

if (this.values && this.values[key] !== undefined) {
selected = this.values[key] === value;
var selectedValue = this.values[key];
selected = Array.isArray(selectedValue)
? selectedValue.indexOf(value) > -1
: selectedValue === value;
}

@@ -278,2 +284,3 @@

value: value,
type: opts.type,
selected: selected,

@@ -351,5 +358,15 @@ toggle: toggle,

'radio-group': {
path: 'partials/forms/radio-group',
renderWith: optionGroup
path: 'partials/forms/option-group',
renderWith: optionGroup,
options: {
type: 'radio'
}
},
'checkbox-group': {
path: 'partials/forms/option-group',
renderWith: optionGroup,
options: {
type: 'checkbox'
}
},
select: {

@@ -456,2 +473,4 @@ path: 'partials/forms/select',

res.locals.currencySymbol = '£';
res.locals.currency = function () {

@@ -468,6 +487,16 @@ return function (txt) {

}
return '£' + value;
return res.locals.currencySymbol + value;
};
};
res.locals.currencyOrFree = function () {
return function (txt) {
var value = parseFloat(hoganRender(txt, this));
if (value === 0) {
return t('free');
}
return res.locals.currency()(txt);
};
};
res.locals.date = function () {

@@ -500,2 +529,9 @@ return function (txt) {

res.locals.capscase = function () {
return function (txt) {
txt = hoganRender(txt, this);
return txt.substr(0, 1).toUpperCase() + txt.substr(1);
};
};
res.locals.selected = function () {

@@ -502,0 +538,0 @@ return function (txt) {

2

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

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

checkbox-required
checkbox-group
input-submit

@@ -92,2 +93,4 @@ textarea

- `className`: A string or array of string class names.
- `labelClassName`: A string or array of string class names for the label, hint, and error section.
- `labelTextClassName`: A string or array of string class names for the label text.
- `label`: The intended value of the HTML `label` attribute.

@@ -94,0 +97,0 @@ - `type`: The value of the HTML input `type` attribute.

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

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