0

I'm interested in the full list of all possible abilities Drupal-specific Twig has to work with files, i.e. reading, writing, copying, renaming etc. Including all the abilities Twig itself has regardless of CMS. So please don't remove the tag Twig.

Yet I just know about loading template partials like

{% include '@themename/header.html.twig' %}

It's an example of reading a file by its filesystem path

Can Drupal-specific Twig or Twig itself also rename a file? Or copy with renaming? And so on

stckvrw
  • 1,689
  • 18
  • 42
  • Unsure what the question is here. Twig is a templating engine and doesn't have the ability to create/rename/edit files by default – DarkBee Sep 14 '22 at 14:09
  • Does this answer your question? [Extending or including - what is better in Twig?](https://stackoverflow.com/questions/7051743/extending-or-including-what-is-better-in-twig) – DarkBee Sep 14 '22 at 14:10
  • @DarkBee Do you mean Twig can only read files and only templates/partials? – stckvrw Sep 14 '22 at 14:13
  • That is correct, you have `include`, `embed`, `extend`, `use` and `import`. The only files twig is able to "create" are the "compiled" templates in `PHP` if the cache is enabled – DarkBee Sep 14 '22 at 14:15
  • @DarkBee Could you post a link with information about the last you've mentioned, i.e. creating compiled templates in PHP? Especially Drupal-specific – stckvrw Sep 14 '22 at 14:17
  • 1
    That's addressed in the note below the [basic documentation](https://twig.symfony.com/doc/2.x/api.html#basics). There is also the `cache`-tag, but isn't enabled by default - [cache](https://twig.symfony.com/doc/3.x/tags/cache.html) – DarkBee Sep 14 '22 at 14:20

0 Answers0