Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove first line while rendering data in symfony2

I am currently working on symfony2 framework. I want the html data that twig file renders in one file.

My code:

    $myfile = fopen("somefile.html", "w");
    $data = $this->render("somefile.html.twig");
    fwrite($myfile, $data);

This works fine but in addition with html data I get the following line
"HTTP/1.0 200 OK
Cache-Control: no-cache
Date:       Tue, 02 Jun 2015 07:50:16 GMT"

as a staring lines I want to remove them is it possible via symfony or I have use regex?

like image 245
CodeFather Avatar asked Jun 02 '15 09:06

CodeFather


1 Answers

Try to use renderView() instead of render().

$myfile = fopen("somefile.html", "w");
$data = $this->renderView("somefile.html.twig");
fwrite($myfile, $data);
like image 100
Danila Ganchar Avatar answered Nov 01 '22 17:11

Danila Ganchar