In Drupal 7, for a view where I wanted to replace every instance of ‘am’ with ‘a.m.’ (with a similar replacement for pm/p.m.) in the output, I did this:
function mymodule_views_post_render(&$ view, &$ output, &$ cache) { if ($ view->name == 'target_view') { $ replace_pairs = array( ' am ' => ' a.m. ', ' pm ' => ' p.m. ', ); $ output = strtr($ output, $ replace_pairs); } }
How do I achieve the same result in Drupal 8? The documentation for the D8 version of hook_views_post_render() is broken/incomplete, but it does mention strtr(), so I imagine something similar should work.
I’ve already figured out that my if statement will need to test against $ view-storage->id() instead, and I’ve noticed that $ output is an array (rather than a string) in D8, but I’m not seeing anything appropriate to target in that array. I am new to D8; can someone show me the way?