symfony2 generate static html with twig

symfony, twig

Solution

If you check documentation more carefully, you'd find this chapter, which says:

$content = $this->renderView('AcmeHelloBundle:Hello:index.html.twig', array('name' => $name));

Problem

Is there a way to put the html code from a twig template into a html file. I mean, in this case ``` $html = $this->render('SiteBundle:Generated:home_news.html.twig', array('news' => $news))->getContent(); ``` Is there a way where I can do this? ``` $html->output($html_file); ``` And it gerenates a html file with the template. I'm doing this because I have news from a wordpress blog and I want to show the latest news in the homepage. So I would want to put the news of my site in a static file to avoid to generate it with each home request.

Original source