1.0.2 • Published 11 years ago

spice v1.0.2

Weekly downloads
5
License
-
Repository
github
Last release
11 years ago

Spice

No-frills string interpolation library.

var spice = require('spice')
spice('Hello, {:subject}!', { subject: 'world' })
// => (string) "Hello, world!"

Or, alternatively, mess with the String#prototype:

var spice = require('spice')
String.prototype.format = function(mappings) {
  return spice(this, mappings)
}

'Hello, {:subject}!'.format({
  subject: 'world'
})
// => (string) "Hello, world!"

Installing

Just grab it from NPM for the easy-modo install:

$ npm install spice
# Then require it as usual
node> var spice = require('spice')

Testing

The test cases uses Mocha, Noire and Sinon. Just grab everything from NPM and run the test-cases by issuing mocha from the command line:

$ npm install -g mocha
$ npm install --dev    # To grab the testing dependencies
$ npm install sinon    # It's not listed in --dev because C++ deps
$ npm run-script test

Licence

Spice is licensed under the delicious and permissive MIT licence. You can happily copy, share, modify, sell or whatever — refer to the actual licence text for less information:

$ less LICENCE