Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Recommended Twig file extension

Is there a recommended file extension for Twig templates? I've seen the following used, and would like to be consistent with the majority of other developers.

  • myTemplate.html.twig
  • myTemplate.twig
  • myTemplate.html
  • myTemplate.tmpl
like image 989
user1032531 Avatar asked Sep 21 '14 14:09

user1032531


People also ask

What file type is Twig?

File created by Twig, a PHP optimizing template engine; contains a template that will be generated into a specific final format, such as a HTML, JavaScript, XML, or CSS based file; the twig extension determines what engine should be used to create the final format whether it's the Twig or PHP engine.

How do I open a Twig file in my browser?

If you cannot open your TWIG file correctly, try to right-click or long-press the file. Then click "Open with" and choose an application. You can also display a TWIG file directly in the browser: Just drag the file onto this browser window and drop it.

How do Twig files work?

Twig works by taking all the hocus pocus out of template design. Templates are basically just text files that contain variables or expressions that are replaced by values as the template is evaluated. Tags are also an important part of a template file, as these control the logic of the template itself.

Is Twig a template engine?

Twig is a modern template engine for PHPSecure: Twig has a sandbox mode to evaluate untrusted template code. This allows Twig to be used as a template language for applications where users may modify the template design.


1 Answers

Normally you define the format before the .twig extension. So when you work with Symfony2 for example you can define the output format.

myTemplate.json.twig for example. So normally you should use that format. But you don't need that.

Here is an issue but you can see how it works

https://github.com/symfony/symfony/issues/2920

like image 95
René Höhle Avatar answered Oct 07 '22 05:10

René Höhle