multiple replaces on a richtext

So i have a richtext module in my template now i want to work with multiple variables that can be used in the text liks

[score] [location]

now i do a replace on the value for the score, but when i want to do also one for location. it doesn’t work.

{{ module.heading_content | replace('[score]', review.globalScore) | replace('[location]', review.location) }}

any idea how to fix this or another solution to this ?

Hi, @Elty :waving_hand: Welcome to our community! Thanks for including your code example. I have a few basic troubleshooting steps that will hopefully give our community members more details.

  • Ensure that the review object has properties globalScore and location and they are not null or undefined. You could debug this by checking the values of these properties before the replace function is called
  • There might be leading or trailing spaces in your placeholders. Make sure that ‘[score]’ in your content doesn’t have spaces like ‘[ score ]’. The same applies to ‘[location]’
  • The replace function is case-sensitive. Make sure the casing of your placeholders in the content matches with the ones in the replace function

If you’ve checked all of the above and the issue persists, please share more details about your review object and the content you are trying to replace.

Thank you! — Jaycee

Hey Jaycee, thanks for responding.

Sadly enough these things are checked. But the problem still excists.

Do you have an idea if it is possible to do 2 replace macro’s at 1 time?