I'm new to mustache: In my company we are using mustache to render placeholders. I have read the manual in https://mustache.github.io/ and some other tutorials but could not find nothing that helps me detect placeholders inside some url.
Example: //workflow/v99/history/{{ espisodeId }}
EpisodeId is a Placeholder that a user as put in a URL stored in a database.
I need to be able to get this URL from the database and be able to detect if it as placeholders and where they are located in the url. I can split the url by / ... but how to detect if it has placeholders with mustache?
Thanks for the help you can give me.
You can use regex
to check if there is a mustache in the url by /{{.*?}}/
and test
method.
let url = 'workflow/v99/history/{{ espisodeId }}'
let hasMustache = (url) => {
return /{{.*?}}/.test(url);
}
console.log(hasMustache(url));