string-sub

0.0.1 • Public • Published

string-sub Build Status

Super lightweight string substitution module.

This module is a very simple string substitution module that allows for either key names, or index positions as the placeholder.

Install

$ npm install --save string-sub

Usage

Basic usage

var sub = require('string-sub');

sub('Hello {0}!', 'world');
// => Hello world!

Using variable arguments

sub('Hello {0}, {1}!', 'world', 'nice to meet you');
// => Hello world, nice to meet you!

Using objects

sub('Hello {subject}, {greeting}!', {greeting: 'nice to meet you', subject: 'world'});
// => Hello world, nice to meet you!

Using arrays

sub('Hello {0}, {1}!', ['world', 'nice to meet you']);
// => Hello world, nice to meet you!

License

MIT © Nate Cavanaugh

Readme

Keywords

none

Package Sidebar

Install

npm i string-sub

Weekly Downloads

165

Version

0.0.1

License

MIT

Last publish

Collaborators

  • natecavanaugh