An open API service indexing awesome lists of open source software.

https://github.com/devinus/peachfuzz

Simple Mustache inspired string substitution microlibrary
https://github.com/devinus/peachfuzz

Last synced: 7 months ago
JSON representation

Simple Mustache inspired string substitution microlibrary

Awesome Lists containing this project

README

          

# peachfuzz

[![Travis CI Status](https://img.shields.io/travis/devinus/peachfuzz.svg)](https://travis-ci.org/devinus/peachfuzz)
[![Coveralls Status](https://img.shields.io/coveralls/devinus/peachfuzz.svg)](https://coveralls.io/r/devinus/peachfuzz)

![Peach Fuzz](peachfuzz.jpg)

Simple Mustache inspired string substitution.

## API

```ts
peachfuzz(template: string, context: Object, transform: Function): string
```

## Usage

```js
var peachfuzz = require('peachfuzz');

peachfuzz('Hello {{name}}', { name: 'Devin' }); //=> 'Hello Devin'
```

`peachfuzz` takes an optional `transform` argument that allows values pulled
from the context to be transformed before substitution:

```js
var peachfuzz = require('peachfuzz');

var template = 'https://swag.shop/?product={{product}}';
var context = { product: 'Moustache Wax' };
peachfuzz(template, context, encodeURIComponent);
//=> 'https://swag.shop/?product=Moustache%20Wax'
```