private function prepareAssetManager(AssetFactory $af, \Twig_Environment $twig, array $templates)
    {
        $am = new LazyAssetManager($af);
        $am->setLoader('twig', new TwigFormulaLoader($twig));

        foreach ($templates as $template) {
            $resource = new TwigResource($twig->getLoader(), $template);
            $am->addResource($resource, 'twig');
        }

        return $am;
    }