Skip to content

Instantly share code, notes, and snippets.

@SethVandebrooke
Created July 6, 2018 15:42
Show Gist options
  • Save SethVandebrooke/4fe3523c4465fbff425b72322082fc7d to your computer and use it in GitHub Desktop.
Save SethVandebrooke/4fe3523c4465fbff425b72322082fc7d to your computer and use it in GitHub Desktop.
Process JS in your html
function processJSin(target) {
var html = target.innerHTML;
var temp = html.match(/\{\{.*\}\}/);
if (temp !== null) {
temp.forEach(function(item){
var e = item.replace("{{","").replace("}}","");
html = html.replace(item,eval(e));
});
target.innerHTML = html;
}
}
processJSin(document.body);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment