Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

symfony2 generate static html with twig

Tags:

twig

symfony

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.

like image 443
Lt. Avatar asked Nov 22 '12 11:11

Lt.


1 Answers

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

$content = $this->renderView('AcmeHelloBundle:Hello:index.html.twig', array('name' => $name));
like image 187
Vitalii Zurian Avatar answered Sep 28 '22 06:09

Vitalii Zurian