npm.io
1.0.0 • Published 12 years ago

bloody-compile

Licence
MIT
Version
1.0.0
Deps
0
Vulns
0
Weekly
0

compile

compile is a method to perform simple replacements in JavaScript.

browser support

require

var compile = require("compile")

Examples

You can pass :

Arguments

If arguments.length exceeds 2, arguments are used as primary keys.

compile("{{0}} - {{1}} - {{2}}", "foo", "bar", "baz") 
/* -> */ "foo - bar - baz"
Arrays
compile("{{0}} - {{1}} - {{2}}", ["foo", "bar", "baz"]) 
/* -> */ "foo - bar - baz"
Strings
compile("this is {{*}}", "foo") 
/* -> */ "this is foo"
Objects
compile("{{foo}} {{bar.baz}}!", {foo:"hello", bar:{baz:"yourself"}}) 
/* -> */ "hello yourself!"