Simple Swap is a minimalistic template engine for string interpolation in JavaScript, inspired by swap.js. It allows you to easily inject values into a string template.
- Simple and lightweight
- No external dependencies
- Easy to integrate and use in any JavaScript project
Since this is a basic project example, you can integrate it directly by copying the index.js
file into your project.
Here is a quick example of how to use Simple Swap:
const simpleSwap = require('./index');
const template = '{name} is {age} years old.';
const data = { name: 'Alex', age: '30' };
console.log(simpleSwap(template, data));
// Output: Alex is 30 years old.
Ensure you have Node.js installed, then run the following command to execute the tests:
npm install
npm test