diff --git a/Gruntfile.js b/Gruntfile.js
index a2298e83..ebfea8f9 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -28,7 +28,6 @@ module.exports = function(grunt) {
],
js_files_for_standalone: [
'node_modules/jquery-extendext/jQuery.extendext.js',
- 'node_modules/dot/doT.js',
'dist/js/query-builder.js'
]
});
diff --git a/README.md b/README.md
index 262fd046..682a90dc 100644
--- a/README.md
+++ b/README.md
@@ -7,7 +7,9 @@
[](https://david-dm.org/mistic100/jQuery-QueryBuilder)
[](https://gitlocalize.com/repo/5259/whole_project?utm_source=badge)
-jQuery plugin offering an simple interface to create complex queries.
+jQuery plugin offering a simple interface to create complex queries.
+
+**Now with 100% less unsafe-eval nonsense!**
[](https://querybuilder.js.org)
@@ -43,19 +45,16 @@ jQuery-QueryBuilder is available on [jsDelivr](https://www.jsdelivr.com/package/
* [jQuery 3](https://jquery.com)
* [Bootstrap 3](https://getbootstrap.com/docs/3.3) (CSS only)
* [jQuery.extendext](https://github.com/mistic100/jQuery.extendext)
- * [doT.js](https://olado.github.io/doT)
* [MomentJS](https://momentjs.com) (optional, for Date/Time validation)
* [SQL Parser](https://github.com/mistic100/sql-parser) (optional, for SQL methods)
* Other Bootstrap/jQuery plugins used by plugins
-($.extendext and doT.js are directly included in the [standalone](https://github.com/mistic100/jQuery-QueryBuilder/blob/master/dist/js/query-builder.standalone.js) file)
+($.extendext is directly included in the [standalone](https://github.com/mistic100/jQuery-QueryBuilder/blob/master/dist/js/query-builder.standalone.js) file)
### Browser support
* Internet Explorer >= 9
* All other recent browsers
-
-
## Build
#### Prerequisites
@@ -65,7 +64,8 @@ jQuery-QueryBuilder is available on [jsDelivr](https://www.jsdelivr.com/package/
#### Run
-Install Node dependencies `npm install` then run `grunt` in the root directory to generate production files inside `dist`.
+Install Node dependencies `
+` then run `grunt` in the root directory to generate production files inside `dist`.
#### Options
diff --git a/examples/index.html b/examples/index.html
index 8fc91c18..282cffe6 100644
--- a/examples/index.html
+++ b/examples/index.html
@@ -116,7 +116,6 @@
Output
-
diff --git a/package.json b/package.json
index 14a80bfd..634deeb6 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
- "name": "jQuery-QueryBuilder",
- "version": "2.5.0",
+ "name": "jQuery-QueryBuilder-no-eval",
+ "version": "2.6.0",
"author": {
"name": "Damien \"Mistic\" Sorel",
"email": "contact@git.strangeplanet.fr",
@@ -10,7 +10,6 @@
"main": "dist/js/query-builder.js",
"dependencies": {
"bootstrap": "^3.4.1",
- "dot": "^1.1.3",
"jquery": "^3.5.1",
"jquery-extendext": "^1.0.0",
"moment": "^2.29.1",
@@ -64,10 +63,10 @@
"homepage": "https://querybuilder.js.org",
"repository": {
"type": "git",
- "url": "git://github.com/mistic100/jQuery-QueryBuilder.git"
+ "url": "git://github.com/lol768/jQuery-QueryBuilder.git"
},
"bugs": {
- "url": "https://github.com/mistic100/jQuery-QueryBuilder/issues"
+ "url": "https://github.com/lol768/jQuery-QueryBuilder/issues"
},
"scripts": {
"build": "grunt",
diff --git a/src/.wrapper.js b/src/.wrapper.js
index 732ae480..2b326090 100644
--- a/src/.wrapper.js
+++ b/src/.wrapper.js
@@ -1,14 +1,14 @@
(function(root, factory) {
if (typeof define == 'function' && define.amd) {
- define(['jquery', 'dot/doT', 'jquery-extendext'], factory);
+ define(['jquery', 'jquery-extendext'], factory);
}
else if (typeof module === 'object' && module.exports) {
- module.exports = factory(require('jquery'), require('dot/doT'), require('jquery-extendext'));
+ module.exports = factory(require('jquery'), require('jquery-extendext'));
}
else {
- factory(root.jQuery, root.doT);
+ factory(root.jQuery);
}
-}(this, function($, doT) {
+}(this, function($) {
"use strict";
@@js
diff --git a/src/main.js b/src/main.js
index f799af6f..1996c440 100644
--- a/src/main.js
+++ b/src/main.js
@@ -122,7 +122,7 @@ var QueryBuilder = function($el, options) {
this.templates[tpl] = QueryBuilder.templates[tpl];
}
if (typeof this.templates[tpl] == 'string') {
- this.templates[tpl] = doT.template(this.templates[tpl]);
+ console.error('Pre-compile your templates, strings are no longer supported.');
}
}, this);
diff --git a/src/template.js b/src/template.js
index 004d4693..951f4fc0 100644
--- a/src/template.js
+++ b/src/template.js
@@ -1,109 +1,256 @@
-QueryBuilder.templates.group = '\
-';
-
-QueryBuilder.templates.rule = '\
- \
- \
- {{? it.settings.display_errors }} \
-
\
- {{?}} \
-
\
-
\
-
\
-
';
-
-QueryBuilder.templates.filterSelect = '\
-{{ var optgroup = null; }} \
- \
- {{? it.settings.display_empty_filter }} \
- {{= it.settings.select_placeholder }} \
- {{?}} \
- {{~ it.filters: filter }} \
- {{? optgroup !== filter.optgroup }} \
- {{? optgroup !== null }}{{?}} \
- {{? (optgroup = filter.optgroup) !== null }} \
- \
- {{?}} \
- {{?}} \
- {{= it.translate(filter.label) }} \
- {{~}} \
- {{? optgroup !== null }} {{?}} \
- ';
-
-QueryBuilder.templates.operatorSelect = '\
-{{? it.operators.length === 1 }} \
- \
-{{= it.translate("operators", it.operators[0].type) }} \
- \
-{{?}} \
-{{ var optgroup = null; }} \
- \
- {{~ it.operators: operator }} \
- {{? optgroup !== operator.optgroup }} \
- {{? optgroup !== null }}{{?}} \
- {{? (optgroup = operator.optgroup) !== null }} \
- \
- {{?}} \
- {{?}} \
- {{= it.translate("operators", operator.type) }} \
- {{~}} \
- {{? optgroup !== null }} {{?}} \
- ';
-
-QueryBuilder.templates.ruleValueSelect = '\
-{{ var optgroup = null; }} \
- \
- {{? it.rule.filter.placeholder }} \
- {{= it.rule.filter.placeholder }} \
- {{?}} \
- {{~ it.rule.filter.values: entry }} \
- {{? optgroup !== entry.optgroup }} \
- {{? optgroup !== null }}{{?}} \
- {{? (optgroup = entry.optgroup) !== null }} \
- \
- {{?}} \
- {{?}} \
- {{= entry.label }} \
- {{~}} \
- {{? optgroup !== null }} {{?}} \
- ';
+function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
+
+function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
+
+function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
+
+var templates = {
+ /* eslint-disable */
+ group: function anonymous(it) {
+ var out = '';
+ return out;
+ },
+ rule: function anonymous(it) {
+ var out = ' ';
+
+ if (it.settings.display_errors) {
+ out += '
';
+ }
+
+ out += '
';
+ return out;
+ },
+ filterSelect: function anonymous(it) {
+ var out = '';
+ var optgroup = null;
+ out += ' ';
+
+ if (it.settings.display_empty_filter) {
+ out += ' ' + it.settings.select_placeholder + ' ';
+ }
+
+ out += ' ';
+ var _val1 = it.filters;
+
+ if (_val1) {
+ var _iterator2 = _createForOfIteratorHelper(_val1),
+ _step2;
+
+ try {
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
+ var filter = _step2.value;
+ out += ' ';
+
+ if (optgroup !== filter.optgroup) {
+ out += ' ';
+
+ if (optgroup !== null) {
+ out += '';
+ }
+
+ out += ' ';
+
+ if ((optgroup = filter.optgroup) !== null) {
+ out += ' ';
+ }
+
+ out += ' ';
+ }
+
+ out += ' " + it.translate(filter.label +> ';
+ }
+ } catch (err) {
+ _iterator2.e(err);
+ } finally {
+ _iterator2.f();
+ }
+ }
+
+ out += ' ';
+
+ if (optgroup !== null) {
+ out += ' ';
+ }
+
+ out += ' ';
+ return out;
+ },
+ operatorSelect: function anonymous(it) {
+ var out = '';
+
+ if (it.operators.length === 1) {
+ out += ' ' + it.translate("operators", it.operators[0].type) + ' ';
+ }
+
+ out += ' ';
+ var optgroup = null;
+ out += ' ';
+ var _val1 = it.operators;
+
+ if (_val1) {
+ var _iterator3 = _createForOfIteratorHelper(_val1),
+ _step3;
+
+ try {
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
+ var operator = _step3.value;
+ out += ' ';
+
+ if (optgroup !== operator.optgroup) {
+ out += ' ';
+
+ if (optgroup !== null) {
+ out += '';
+ }
+
+ out += ' ';
+
+ if ((optgroup = operator.optgroup) !== null) {
+ out += ' ';
+ }
+
+ out += ' ';
+ }
+
+ out += ' " + it.translate operators , operator.type +> ';
+ }
+ } catch (err) {
+ _iterator3.e(err);
+ } finally {
+ _iterator3.f();
+ }
+ }
+
+ out += ' ';
+
+ if (optgroup !== null) {
+ out += ' ';
+ }
+
+ out += ' ';
+ return out;
+ },
+ ruleValueSelect: function anonymous(it) {
+ var out = '';
+ var optgroup = null;
+ out += ' " ; + + if (it.rule.filter.placeholder { + out +=' ';
+ }
+
+ out += ' ';
+ }
+
+ out += ' ' + entry.label + ' ';
+ }
+ } catch (err) {
+ _iterator4.e(err);
+ } finally {
+ _iterator4.f();
+ }
+ }
+
+ out += ' ';
+
+ if (optgroup !== null) {
+ out += '';
+ }
+
+ out += ' ';
+ return out;
+ }
+ /* eslint-enable */
+
+};
+
+QueryBuilder.templates = templates;
/**
* Returns group's HTML
diff --git a/tests/index.html b/tests/index.html
index 463bc9eb..f6bfa2fc 100644
--- a/tests/index.html
+++ b/tests/index.html
@@ -27,7 +27,6 @@
-