diff --git a/src/utils/Evaluator.ts b/src/utils/Evaluator.ts
index 55c6cc6f..815259b7 100644
--- a/src/utils/Evaluator.ts
+++ b/src/utils/Evaluator.ts
@@ -18,7 +18,16 @@ export class BaseEvaluator {
evaluate: /\{%([\s\S]+?)%\}/g,
escape: /\{\{\{([\s\S]+?)\}\}\}/g,
};
- public static noeval: boolean = false;
+ private static _noeval = false;
+
+ public static get noeval(): boolean {
+ return BaseEvaluator._noeval;
+ }
+
+ public static set noeval(value: boolean) {
+ BaseEvaluator._noeval = value;
+ }
+
public static evaluator(func: any, ...params: any) {
if (Evaluator.noeval) {
console.warn('No evaluations allowed for this renderer.');
diff --git a/src/utils/__tests__/Evaluator.test.ts b/src/utils/__tests__/Evaluator.test.ts
index c4763b9d..fd5ee5aa 100644
--- a/src/utils/__tests__/Evaluator.test.ts
+++ b/src/utils/__tests__/Evaluator.test.ts
@@ -1,5 +1,6 @@
import { Evaluator } from '../Evaluator';
import { assert } from 'chai';
+import { noop } from 'lodash';
describe('Evaluator', function () {
it('Should be able to interpolate a string with Evaluator', function () {
@@ -228,4 +229,26 @@ describe('Evaluator', function () {
'Sun, 02 May 2021 21:00:00 GMT',
);
});
+
+ it('Should enable or disable evaluation based on the noeval option', function () {
+ Evaluator.noeval = true;
+ assert.equal(
+ Evaluator.evaluator(`{{ data.firstName }}`, {
+ data: {
+ firstName: 'Travis',
+ },
+ }),
+ noop,
+ );
+
+ Evaluator.noeval = false;
+ assert.equal(
+ Evaluator.interpolate(`{{data.firstName }}`, {
+ data: {
+ firstName: 'Travis',
+ },
+ }),
+ 'Travis',
+ );
+ });
});