Used directly by {% setcontent %} but also in other parts.
This code has been split into multiple methods in the spirit of
separation of concerns, but the situation is still far from ideal.
Where applicable each 'concern' notes the coupling in the local
documentation.