Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Horribly simple templating.
JavaScript
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
.gitignore
.travis.yml
README.md
index.js
package.json
test.js

README.md

swap.js

Horribly simple templating.

Build Status

Usage

Swap performs string interpolation.

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.

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

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

Prepend with a backslash to escape a replacement field.

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

console.log(demo) // "This is a field: {bob}."
Something went wrong with that request. Please try again.