Skip to content

Releases: dadi/web-pugjs

v1.1.1

09 Aug 15:14
Compare
Choose a tag to compare

<a name"1.1.1">

1.1.1 (2017-08-09)

Bug Fixes

  • call config.get to retrieve settings (8ce5b883)

v1.1.0

09 Aug 14:07
Compare
Choose a tag to compare

<a name"1.1.0">

1.1.0 (2017-08-09)

New Features

Helper functions

Add a DADI Web configuration setting for helpers, pointing to a directory containing helper files. Each .js helper file will be added as a property to template locals for use within templates.

Configuration

  engines: {
    pug: {
      paths: {
        helpers: 'test/workspace/helpers'
      }
    }
  }

Directory structure

helpers/
|_ trim.js
pages/
|_ partials/
|_ |_ common/
|_ |_ |_ header.pug
|_ |_ contact-info.pug
|_ home.pug

Locals

The function is added to the template locals, along with data objects:

{
  products: [
    { name: 'The Old Man and the Sea' }
  ],
  trim: [Function]
}

Usage

Use the function in templates like so:

h1= trim(product.name)