Has been added in Craft.js 1.1.7
Note : Uses Craft.js
Fills placeholders in a string with data.
// with object
myString.compile(object)
// with string
myString.compile(string)
// with arguments
myString.compile(arg1, arg2, arg3 …)
// with array
myString.compile(array)
{{*}}
outputs the string passed at only argument.
"Hello {{firstName}} {{name}}!".compile({firstName : "John", name : "Smith"})
"Hello John Smith!"
"Hello John {{*}}!".compile("Smith")
"Hello John Smith!"
// accepts nesting
"Hello {{person.firstName}} {{person.name}}!".compile({person : {firstName : "John", name : "Smith"}})
"Hello John Smith!"
"Hello {{0}} {{1}}!".compile("John","Smith")
"Hello John Smith!"
"Hello {{0}} {{1}}!".compile(["John","Smith"])
"Hello John Smith!"
Really nice.
Is Craft,js really necessary. As far as I can see it could be easily implemented with vanilla js :\