diff --git a/src/addons/mod/data/components/search/search.ts b/src/addons/mod/data/components/search/search.ts index ced4e44fe..22d000723 100644 --- a/src/addons/mod/data/components/search/search.ts +++ b/src/addons/mod/data/components/search/search.ts @@ -104,12 +104,26 @@ export class AddonModDataSearchComponent implements OnInit { this.fieldsArray.forEach((field) => { let replace = '[[' + field.name + ']]'; replace = replace.replace(/[-[\]/{}()*+?.\\^$|]/g, '\\$&'); - const replaceRegex = new RegExp(replace, 'gi'); + let replaceRegex = new RegExp(replace, 'gi'); // Replace field by a generic directive. const render = ''; template = template.replace(replaceRegex, render); + + // Replace the field name tag. + replace = '[[' + field.name + '#name]]'; + replace = replace.replace(/[-[\]/{}()*+?.\\^$|]/g, '\\$&'); + replaceRegex = new RegExp(replace, 'gi'); + + template = template.replace(replaceRegex, field.name); + + // Replace the field description tag. + replace = '[[' + field.name + '#description]]'; + replace = replace.replace(/[-[\]/{}()*+?.\\^$|]/g, '\\$&'); + replaceRegex = new RegExp(replace, 'gi'); + + template = template.replace(replaceRegex, field.description); }); // Not pluginable other search elements.