1.0.6 • Published 4 years ago

mustache-formats v1.0.6

Weekly downloads
2
License
ISC
Repository
github
Last release
4 years ago

npm package

mustache-formats

Add some useful formatters to Mustache using Mustache-Wax.

Installation

npm install mustache-formats

or

yarn add mustache-formats

Then to use it simply import it and call render, for example

const renderer = require('mustache-formats');

const result = renderer.render('Date: {{signature_date | date : "DD MMMM YYYY"}}', {
  signature_date: '2019-06-24T16:58:34'
});
// Expect result to be "Date: 24 June 2019"

Formats provided

In this first version, we've defined the following formats:

Date

Take a date (for example in ISO8601) and format it using Moment)

Usage:

{{projectInstallationDate | date : "DD MMMM YYYY" }}

Money

Convert to a number and ensure there are two decimal places

Usage:

{{total | money}}

Sum

Add any number of variables (or numbers) to an initial one. It ignores any that are null or undefined

Usage:

{{value_1 | sum : value_2 : value_3 : value_4}}

String functions: upper, lower, capitalize

As the functions suggest, upper-case, lower-case and capitalise the first letter of each word

Usage:

{{value_string | upper}}
1.0.6

4 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago