Skip to content

Commit

Permalink
regex capture groups
Browse files Browse the repository at this point in the history
  • Loading branch information
dbauszus-glx committed Oct 27, 2023
1 parent f0fafe7 commit cafa265
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions mod/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ module.exports = async (req, res) => {

const template = await languageTemplates(params)

const view = template.replace(/[{]{2}([A-Za-z][A-Za-z0-9]*)[}]{2}/g, matched => {
const view = template.replace(/{{2}([A-Za-z][A-Za-z0-9]*)}{2}/g, matched => {

// regex matches {{ or }}
return params[matched.replace(/[{]{2}|[}]{2}/g, '')] || '';
});
// regex matches {{ or }}
return params[matched.replace(/(^{{)|(}}$)/g, '')] || ''
});

res.send(view);
}

0 comments on commit cafa265

Please sign in to comment.