Security News
Bun 1.2 Released with 90% Node.js Compatibility and Built-in S3 Object Support
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
hmpo-template-mixins
Advanced tools
A middleware that exposes a series of Mustache mixins on res.locals to ease usage of forms, translations, and some general needs.
A middleware that exposes a series of Mustache mixins on res.locals
to ease usage of forms, translations, and some other things.
It takes in two arguments, a fields
object containing field configuration, and an options object.
npm install [--save] hmpo-template-mixins;
var express = require('express');
var i18n = require('i18n-future');
var fields = require('./routes/renew-your-passport/fields');
app.set('view engine', 'html');
app.set('views', path.join(__dirname, '/views'));
app.use(i18n.middleware());
app.use(require('hmpo-template-mixins')(fields, { sharedTranslationsKey: 'passport.renew' }));
app.use(function (req, res) {
// NOTE: res.locals.partials has been set.
res.render('example-template');
});
By default any function set to req.translate
will be used for translation if it exists. For example, that generated using i18n-future middleware.
Allows you override the directory that the module checks for partials in - Default: the root of this project
Allows you to alter the file extension of the templates - Default: 'html'
Prefixes keys for translation - Default: ''
Defines a custom translation method - Default: req.translate
t
time
selected
lowercase
uppercase
hyphenate
date
currency
select
input-text
input-date
input-text-compound
input-text-code
input-number
input-phone
radio-group
checkbox
checkbox-compound
checkbox-required
input-submit
textarea
className
: A string or array of string class names.label
: The intended value of the HTML label
attribute.type
: The value of the HTML input type
attribute.required
: Value applied to aria-required
HTML attribute.hint
: This adds context to the label, which it is a part of, for input text, radio groups and textarea. It is used within the input by aria-describedby for screen readers.maxlength
: Applicable to text-based fields and mapped to the maxlength
HTML attribute.options
: Applicable to HTML select
and radio
controls and used to generate the items of either HTML element.selected
: Applicable to select
, checkbox
, and radio
controls. Will render the selected HTML option/element selected or checked.legend
: Applicable to radio
button controls, which are wrapped in a HTML fieldset
with a legend
element.legendClassName
: Applied as a class name to HTML legend
attribute.toggle
: Can be used to toggle the display of the HTML element with a matching id
. See passports-frontend-toolkit for details.attributes
: A hash of key/value pairs applicable to a HTML textarea
field. Each key/value is assigned as an attribute of the textarea
. For example spellcheck="true"
.FAQs
A middleware that exposes a series of Mustache mixins on res.locals to ease usage of forms, translations, and some general needs.
The npm package hmpo-template-mixins receives a total of 102 weekly downloads. As such, hmpo-template-mixins popularity was classified as not popular.
We found that hmpo-template-mixins demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
Security News
Biden's executive order pushes for AI-driven cybersecurity, software supply chain transparency, and stronger protections for federal and open source systems.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.