I have some text I'd like to alter in the custom output of a views field. For example, if the output contains the word "pancakes" I'd like to replace it with "waffles".

{{ field_recipe_prep__value | replace({'pancakes': "waffles"}) }}

But it's still showing "pancakes" in the output. Are you able to do that kind of twig operation in there or is my syntax wrong?

  • Try removing the whitespace before and after the pipe symbol | – Hudri Apr 2 at 14:46
  • Nope - didn't work unfortunately. – user7355700 Apr 2 at 14:49
  • is my syntax wrong? yes – No Sssweat Apr 3 at 6:20
  • your syntax is correct. have you cleared your cache and twig cache? – Alex Apr 3 at 7:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.