cvc / typo3-twig
Use the Twig template engine within your TYPO3 project.
Installs: 18 058
Dependents: 0
Suggesters: 0
Security: 0
Stars: 9
Watchers: 3
Forks: 6
Open Issues: 14
Type:typo3-cms-extension
Requires
- php: ^8.1
- symfony/console: ^5.4 || ^6.4 || ^7.0
- twig/twig: ^3
- typo3/cms-backend: ^11.5.24 || ^12.4.2
- typo3/cms-core: ^11.5.24 || ^12.4.2
- typo3/cms-extbase: ^11.5.24 || ^12.4.2
- typo3/cms-frontend: ^11.5.24 || ^12.4.2
Requires (Dev)
- cvc/twig-documentor: ^0.3
- ergebnis/composer-normalize: ^2.28
- friendsofphp/php-cs-fixer: ^3.13
- phpstan/phpstan: ^1.5
- phpunit/phpunit: ^10.1
- symfony/var-dumper: ^5.4
- typo3/testing-framework: ^8.2
Replaces
- typo3-ter/cvc_twig: 3.0.0
This package is auto-updated.
Last update: 2024-10-07 08:23:20 UTC
README
This TYPO3 extensions allows you to use the fabulous Twig template engine within your TYPO3 project.
You can use Twig templates in your Extbase controllers or in your TypoScript.
Version compatibility
The following table shows which versions of this package are compatible with which TYPO3 version.
- Version 1 is compatible to TYPO3
8.7
and9.5
. - Version 2 is compatible to TYPO3
10.4
and11.5
. - Version 3 that is developed on the
master
branch is only compatible to TYPO3 v12
Since Version 2, PHP 7.4
is required.
Installation
This extension only works when installed in composer mode. If you are not familiar using composer together with TYPO3 yetyou can find a how to on the TYPO3 website.
Install the extension with the following command:
composer require cvc/typo3-twig
Getting started
Rendering of Twig templates works nearly exactly the same way as rendering Fluid templates.
In contrast to Fluid there are no "layouts" nor "partials" in Twig. Everything is "just" a template. Therefore there are some features missing that you are probably used by Fluid.
Render templates in TypoScript
To render a Twig template you can use the TWIGTEMPLATE
content object.
You can use it similar to the way, Fluid was used before.
The variables
are rendered as content objects and data processing is also possible.
page = PAGE
page.10 = TWIGTEMPLATE
page.10 {
templateName = example.html.twig
variables {
foo = TEXT
foo.value = Bar!
}
templateRootPaths {
10 = EXT:cvc_twig/Resources/Private/TwigTemplates
}
dataProcessing {
10 = TYPO3\CMS\Frontend\DataProcessing\FilesProcessor
10 {
references.fieldName = image
}
}
}
Documentation
The full documentation is available here: cvc_twig Documentation.
Alternatives
This extension is not the first extension that supports rendering Twig templates. We decided to create our own extension, because other extensions were either not maintained anymore, they carried to much overhead or they were not developed close to the Fluid reference implementation.
In the table below you can find other extensions that provides an integration for the Twig template engine: