Created
July 6, 2018 15:42
-
-
Save SethVandebrooke/4fe3523c4465fbff425b72322082fc7d to your computer and use it in GitHub Desktop.
Process JS in your html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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