@nicolas-grekas then it should not be a Twig function but a tag, to respect the Twig semantic.

It is perfectly fine to collect the output separately, but it should be done in the Twig way