Automatically wrap specific text on website in <em> tags …

Dear community,

what’s a good way to wrap/replace a specific string “foo bar baz” in my kirby website, which is written via kirbytext and so on, in $string tags?

Thank you for your help! : )

You can use a kirbytext pre filter:

kirbytext::$pre[] = function($kirbytext, $value) {
  return str_replace('foo bar baz', '<em>foo bar baz</em>', $value);
};
```

Dear texnixe, thank you very much. That works like a charm. : )