Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/gsf/swap.js

Horribly simple templating.
https://github.com/gsf/swap.js

Last synced: 2 months ago
JSON representation

Horribly simple templating.

Awesome Lists containing this project

README

        

# swap.js

Horribly simple templating.

[![Build Status](https://travis-ci.org/gsf/swap.js.png?branch=master)](https://travis-ci.org/gsf/swap.js)

## Usage

Swap performs string interpolation.

```js
var swap = require('swap')

var story = swap('{subject} {action} to the {location}.', {
subject: 'Elle and Dez',
action: 'strolled',
location: 'market'
})

console.log(story) // "Elle and Dez strolled to the market."
```

Comments are contained within exclamation points.

```js
var topSecret = swap('I am here{! with two kittens!}.')

console.log(topSecret) // "I am here."
```

Prepend with a backslash to escape a replacement field.

```js
var demo = swap('This is a field: \{bob}.')

console.log(demo) // "This is a field: {bob}."
```