public function render(
        stdClass $user,
        array $forums,
        array $discussions,
        array $posts
    ) : string {
        // Format the forums and discussion to make them more easily accessed later.
        $forums = array_reduce($forums, function($carry, $forum) {
            $carry[$forum->get_id()] = $forum;
            return $carry;
        }, []);
        $discussions = array_reduce($discussions, function($carry, $discussion) {
            $carry[$discussion->get_id()] = $discussion;
            return $carry;
        }, []);

        $exportedposts = $this->exportedpostsbuilder->build(
            $user,
            $forums,
            $discussions,
            $posts
        );

        if ($this->postprocessfortemplate !== null) {
            // We've got some post processing to do!
            $exportedposts = ($this->postprocessfortemplate)($exportedposts, $forums, $discussions, $user);
        }

        return $this->renderer->render_from_template(
            $this->template,
            ['posts' => array_values($exportedposts)]
        );
    }