Skip to content

Commit

Permalink
Fixed an issue where temlate code is evaluated when rending TextArea …
Browse files Browse the repository at this point in the history
…value
  • Loading branch information
Aliaksandra Ramanenka authored and travist committed Dec 13, 2021
1 parent 202f263 commit 5338340
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/Element.js
Original file line number Diff line number Diff line change
Expand Up @@ -545,13 +545,13 @@ export default class Element {
* @param data
* @return {XML|string|*|void}
*/
interpolate(string, data) {
interpolate(string, data, noeval = false) {
if (typeof string !== 'function' && this.component.content
&& !FormioUtils.Evaluator.templateSettings.interpolate.test(string)) {
string = FormioUtils.translateHTMLTemplate(String(string), (value) => this.t(value));
}

return FormioUtils.interpolate(string, this.evalContext(data));
return FormioUtils.interpolate(string, this.evalContext(data), noeval);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/components/textarea/TextArea.js
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ export default class TextAreaComponent extends TextFieldComponent {
index = index || 0;
if (this.options.readOnly || this.disabled) {
if (this.refs.input && this.refs.input[index]) {
this.setContent(this.refs.input[index], this.interpolate(value));
this.setContent(this.refs.input[index], this.interpolate(value, {}, true));
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/utils/Evaluator.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const Evaluator = {
console.warn('Error while processing template', err, template);
}
},
interpolate(rawTemplate, data) {
interpolate(rawTemplate, data, noeval) {
if (typeof rawTemplate === 'function') {
try {
return rawTemplate(data);
Expand All @@ -49,7 +49,7 @@ const Evaluator = {
if (Evaluator.cache[hash]) {
template = Evaluator.cache[hash];
}
else if (Evaluator.noeval) {
else if (Evaluator.noeval || noeval) {
// No cached template methods available. Use poor-mans interpolate without eval.
return rawTemplate.replace(/({{\s*(.*?)\s*}})/g, (match, $1, $2) => _.get(data, $2));
}
Expand Down

0 comments on commit 5338340

Please sign in to comment.