0.1.2 • Published 10 years ago

replacor v0.1.2

Weekly downloads
8
License
MIT
Repository
github
Last release
10 years ago

replacor Build Status

small module to replace code blocks with custom code, like for css code generators for example.

(technically it's also a very tiny template engine haha)

npm i -S replacor
var rp = require('replacor')

// Replace from a string
var res1 = rp.generate('var {} = 1', 'test') // 'var test = 1'

// You can also replace multiple ones, just keep the order
var res2 = rp.generate('var {} = {}', 'test2', '/()/') // 'var test2 = /()/'

// If you have a lot of them and you don't want to remember the order, you
// can name them
var res3 = rp.generateNamed(
  'var {varName} = {varValue}\
   {functionName}()\
   object.{propertyName}',
   {
     varName: 'test',
     varValue: 'cool var',
     functionName: 'myCoolFunction',
     propertyName: 'generateSparkles'
   }
 ) // 'var test = "cool var" (and so on...)'

license

MIT