
Security News
PodRocket Podcast: Inside the Recent npm Supply Chain Attacks
Socket CEO Feross Aboukhadijeh discusses the recent npm supply chain attacks on PodRocket, covering novel attack vectors and how developers can protect themselves.
hmpo-govuk-template
Advanced tools
Compile govuk mustache template into a more usable format and provide middleware for use in apps
Compiles govuk mustache template into a more usable format and provide middleware for use in apps.
Existing govuk mustache template has simple mustache placeholders for content sections, which necessitates a two step compile process where sections are compiled individually and then again into the parent template.
Compiling the template to replace these placeholders with variables allows for templates to implement the govuk template as a parent partial.
{{< govuk-template}}
{{$main}}
<h1>Page Content</h1>
{{/main}}
{{/ govuk-template}}
npm install [--save] hmpo-govuk-template
The compilation of the template is performed automatically as an npm postinstall hook.
When used as part of an express app, a setup method is provided which will add a static-middleware (using serve-static) to serve the template assets without needing to copy them to any other location.
It will also add the template as a mustache partial with a name of "govuk-template".
require('hmpo-govuk-template').setup(app[, { ... options ...}]);
govukAssetPath
local will need to set to the absolute public asset location.app.use(function (req, res, next) {
res.locals = res.locals || {};
res.locals.govukAssetPath = '/absolute/asset/path'
});
app.use(require('hmpo-govuk-template').template);
{{< govuk-template}}
{{$pageTitle}}An example page{{/pageTitle}}
{{$main}}
<h1>Page Content</h1>
{{/main}}
{{/ govuk-template}}
A number of options can be passed with the app into the setup method:
path
- Sets the base path for the location of static assets - Default: /govuk-assets
Other options are passed onto the serve-static configuration, and more details can be found in the serve-static documentation
There is an example implmentation in '/example'. To run:
cd example
npm install
npm start
FAQs
Compile govuk mustache template into a more usable format and provide middleware for use in apps
The npm package hmpo-govuk-template receives a total of 22 weekly downloads. As such, hmpo-govuk-template popularity was classified as not popular.
We found that hmpo-govuk-template demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 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
Socket CEO Feross Aboukhadijeh discusses the recent npm supply chain attacks on PodRocket, covering novel attack vectors and how developers can protect themselves.
Security News
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.
Product
Socket Firewall is a free tool that blocks malicious packages at install time, giving developers proactive protection against rising supply chain attacks.