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

@ministryofjustice/fb-nunjucks-helpers

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ministryofjustice/fb-nunjucks-helpers - npm Package Compare versions

Comparing version 0.0.7 to 0.0.8

18

lib/fb-nunjucks-data-helpers.js

@@ -40,2 +40,3 @@ const Markdown = require('markdown-it')()

const setItemsLabel = data => {
data = JSON.parse(JSON.stringify(data))
try {

@@ -67,5 +68,18 @@ data = setLabel(data)

data.items = data.items || []
data.items = data.items.map(item => {
data.items = data.items.map((item, index) => {
let hint = item.hint
if (hint && !hint.html) {
hint = {html: hint}
}
let itemId = item.id || item.name
if (!itemId && data.name) {
itemId = `${data.name}-${index}`
}
let html = item.text ? item.text : item.html
html = html || item.label
const id = itemId ? itemId.replace(/\./g, '--') : undefined
const updatedItem = Object.assign({}, item, {
text: item.text ? item.text : item.label
id,
html,
hint
})

@@ -72,0 +86,0 @@ if (data._type !== 'date') {

@@ -129,2 +129,25 @@ const test = require('tape')

const itemsData = setItemsLabel({
name: 'name',
items: [{
text: 'item1text',
id: 'item1id'
}, {
html: 'item2html',
hint: 'hint2html'
}, {
label: 'item3label',
name: 'foo.bar'
}]
})
t.equals(itemsData.items[0].html, 'item1text', 'it should set the item.html property with the value of any text property passed')
t.equals(itemsData.items[1].html, 'item2html', 'it should set the item.html property with the value of any html property passed')
t.equals(itemsData.items[2].html, 'item3label', 'it should set the item.html property with the value of any html property passed')
t.equals(itemsData.items[1].hint.html, 'hint2html', 'it should set the item.html property with the value of any html property passed')
t.equals(itemsData.items[0].id, 'item1id', 'it should use the item.id property if passed explicitly')
t.equals(itemsData.items[1].id, 'name-1', 'it should set the item.id property with the value of any name property passed on the parent data')
t.equals(itemsData.items[2].id, 'foo--bar', 'it should set the item.id property with the value of its name property, substituting dots with double dashes')
t.end()

@@ -131,0 +154,0 @@ })

2

package.json
{
"name": "@ministryofjustice/fb-nunjucks-helpers",
"version": "0.0.7",
"version": "0.0.8",
"description": "Form Builder Nunjucks helpers",

@@ -5,0 +5,0 @@ "main": "lib/fb-nunjucks-helpers.js",

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