0.0.25 • Published 4 years ago

@ministryofjustice/fb-nunjucks-helpers v0.0.25

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

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

0.0.25

4 years ago

0.0.24

4 years ago

0.0.23

5 years ago

0.0.22

5 years ago

0.0.21

5 years ago

0.0.20

5 years ago

0.0.19

5 years ago

0.0.18

5 years ago

0.0.17

5 years ago

0.0.16

5 years ago

0.0.15

6 years ago

0.0.14

6 years ago

0.0.13

6 years ago

0.0.12

6 years ago

0.0.11

6 years ago

0.0.10

6 years ago

0.0.9

6 years ago

0.0.8

6 years ago

0.0.7

6 years ago

0.0.6

6 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago