bloody-compile
v1.0.0
Published
compile is a method to perform simple replacements in JavaScript.
Downloads
3
Readme
compile
compile is a method to perform simple replacements in JavaScript.
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!"