DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Simple Templating Engine
this will replace variables within a string that are denoted as [[variable]] and will replace it with the value of data[variable]
function parseTemplate(content, data) {
content=String(content);
re = /\[\[(\w*)\]\]/gi;
return (
content.replace(
re,
function ($1,$2,$3) {
return data[$2];
}
)
);
}





