Skip to content

Commit

Permalink
Merge branch 'pull/830' into demo
Browse files Browse the repository at this point in the history
  • Loading branch information
carson committed Feb 19, 2022
2 parents 4edeae9 + cf0a1a3 commit f7a51bd
Showing 1 changed file with 4 additions and 20 deletions.
24 changes: 4 additions & 20 deletions www/js/demo/it.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,13 @@ function addScript(url) {
}

function interpolate(str, params) {
var returnStr = "";
try {
var charArray = Array.from(str);
while (charArray.length > 0) {
var current = charArray.shift();
if (current === "$" && charArray[0] === "{") {
var evalStr = "(function(env) { with(env) { return "
charArray.shift();
while (charArray.length > 0 && charArray[0] !== "}") {
evalStr += charArray.shift()
}
charArray.shift();
evalStr += " } })";
// console.log("Evaling", evalStr);
returnStr += eval(evalStr)(params);
} else {
returnStr += current;
}
}
return eval(
`env => { with (env) { return \`${str.replace(/`/, '\\`'}\` } }`
)(params)
} catch (e) {
returnStr = e.message;
return e.message;
}
return returnStr;
}

function initMockRequests() {
Expand Down

0 comments on commit f7a51bd

Please sign in to comment.