Skip to content

Commit

Permalink
Substitute parser null value (#2221)
Browse files Browse the repository at this point in the history
  • Loading branch information
maurofmferrao authored Nov 13, 2023
1 parent 8f01f62 commit 8360ded
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions modules/src/xibo-substitutes-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,9 @@ jQuery.fn.extend({
const items = [];
const parser = new RegExp('\\[.*?\\]', 'g');
const pipeParser = new RegExp('\\|{1}', 'g');
this.each(function() {
this.each(function(_idx, data) {
// Parse the template for a list of things to substitute, and match those
// with content from items.
const data = this;
let replacement = template;
let match = parser.exec(template);
while (match != null) {
Expand Down Expand Up @@ -73,6 +72,9 @@ jQuery.fn.extend({
});
}

// If value is null, set it as empty string
(value === null) && (value = '');

// Finally set the replacement in the template
replacement = replacement.replace(match[0], value);

Expand Down

0 comments on commit 8360ded

Please sign in to comment.