Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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.
- Host: GitHub
- URL: https://github.com/gsf/swap.js
- Owner: gsf
- Created: 2012-09-05T05:10:03.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2013-05-02T12:49:39.000Z (over 11 years ago)
- Last Synced: 2024-10-20T02:53:26.766Z (3 months ago)
- Language: JavaScript
- Homepage:
- Size: 129 KB
- Stars: 2
- Watchers: 2
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
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}."
```