jsexpr
Version:
String and JSON expression interpolator and evaluator. Interpolates or evaluates a string against a json object, or transforms an object into another based on a json template
32 lines (30 loc) • 769 B
HTML
<html>
<head>
<script src="../../dist/browser/jsexpr.js"></script>
</head>
<body>
<script>
var fn = jsexpr.fn("(${host}=='mymachine' || ${host}=='yourmachine') && ${appName}=='su'");
var expr = jsexpr.expr("/var/${date}/${client.address}/file.log");
var jsexpr = jsexpr.expr({
time : "${client}/${address.host}:${address.port}",
data : {
request : {
headers : "${headers}"
}
}
});
console.log(fn({host:"mymachine",appName:23}));
console.log(expr({date:"2017-01-01",client:{address:"localhost"}}));
console.log(jsexpr({
client : "HOST001",
address : {
host : "localhost",
port : 8080
},
headers : "Content-Type: application/json"
}));
</script>
</body>
</html>