Create equivalent HTML twig file template?

I would like to know if it is possible to create {filename}.htmlfor everyone {filename}.html.twig? I know that one solution is to copy and paste the source code from the browser, but is there a more efficient way to do this?

Thanks in advance.

+1
source share
2 answers

Such a solution, I think, will satisfy your needs.

curl www.yoururl.com > /path/to/yourfolder/file.html

See below stories if you are interested.

Story

A few months ago I was working on the yii2 project. The index page loaded after 3 seconds due to a response from external services. Cloudflare and other caching scripts did not succeed - I came up with a maximum of 2.5 seconds.

2-3 :) , index.html ( yii2 web) 2 .

- (< 0,2s), .

, ,

curl www.example.com > /path/to/web/index.html

+1

, Twig_Environment init Twig

class MyTwigEnvironment extends \Twig_Environment {
    public function render($name, array $context = array())
    {
        $html = $this->loadTemplate($name)->render($context, $site_id);
        file_put_contents('path/to/cache/folder'.$name.'.twig', $html);
        chmod('path/to/cache/folder'.$name.'.twig', 0664);
        return $html;
    }   
 }

$twig = new MyTwigEnvironment($loader, $options);
echo $twig->render('some_template.html');
0

Source: https://habr.com/ru/post/1657295/


All Articles