-
Notifications
You must be signed in to change notification settings - Fork 104
/
json2html.es6.js
37 lines (28 loc) · 1.13 KB
/
json2html.es6.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// json2html.es6.js 3.0.0
// https://www.json2html.com
// (c) 2006-2022 Crystalline Technologies
// json2html may be freely distributed under the MIT license.
(function() {
"use strict";
// ES6 Support
// --------------
// Establish the root object, `window` (`self`) in the browser, `global`
// on the server, or `this` in some virtual machines. We use `self`
// instead of `window` for `WebWorker` support.
var root = typeof self == 'object' && self.self === self && self ||
typeof global == 'object' && global.global === global && global ||
this ||
{};
if(!root.json2html) root.json2html = {};
/* ---------------------------------------- Private Methods ------------------------------------------------ */
//Add es6 support
root.json2html.es6 = {
//Adds support for Template Literals
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals
"interpolate":function(params) {
var names = Object.keys(params),
vals = Object.values(params);
return new Function(...names, `return \`${this}\`;`)(...vals);
}
};
}());