This package has been deprecated

Author message:

This package will not receive ongoing development

@ministryofjustice/fb-nunjucks-helpers

0.0.25 • Public • Published

fb-nunjucks-helpers

Form Builder Nunjucks helpers

Usage

npm install @ministryofjustice/fb-nunjucks-helpers

Set up

const fbNunjucksHelpers = require('fb-nunjucks-helpers')
let nunjucksEnv = nunjucks.configure(views, options)
nunjucksEnv = fbNunjucksHelpers.init(nunjucksEnv)

Adding macros

nunjucksEnv.add(macroPaths)

Adding to a specific namespace

nunjucksEnv.add(macroPaths, namespace)

Global methods available in Nunjucks templates

callBlock

{{ callBlock(data) }}

{{ callBlock({
  _id: 'blockId;,
  _type: 'blockType',
  ...
}) }}

callBlocks

{{ callBlocks([data, data2, data3]) }}

callMacro

{{ callMacro(macroPath, data) }}

setObject

{% set foo = setObject(foo, {prop: 'value'}) %}

setObjectProperty

{% set foo = setObjectProperty(foo, 'prop', 'value') %}

addGlobal

{% set varSink = addGlobal('globalProp', 'value') %}

Test assets

The macro files used for testing are located in lib/spec/macros

Readme

Keywords

none

Package Sidebar

Install

npm i @ministryofjustice/fb-nunjucks-helpers

Weekly Downloads

3

Version

0.0.25

License

MIT

Unpacked Size

33.1 kB

Total Files

26

Last publish

Collaborators

  • gregtyler
  • moj-igor
  • ma226860
  • hmpps-digital-prison-reporting
  • probation-integration-bot
  • jbrightonmoj
  • solidgoldpig
  • umaar
  • todderz
  • romidane
  • emileswarts
  • elena_vi
  • stevemarshall
  • adamsilver
  • asmega
  • sequencemedialimited
  • form-builder-team
  • form-builder-developers
  • simonwhatley
  • johnnolan
  • paulmassey