项目作者: cvc-digital

项目描述 :
Integrates the Twig template enginge into TYPO3.
高级语言: PHP
项目地址: git://github.com/cvc-digital/typo3-twig.git
创建时间: 2018-11-26T14:06:25Z
项目社区:https://github.com/cvc-digital/typo3-twig

开源协议:GNU General Public License v3.0

下载


Twig Extension for TYPO3

Build Status
GitHub license
Packagist
TYPO3 Version
codecov

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 and 9.5.
  • Version 2 is compatible to TYPO3 10.4 and 11.5.
  • Version 3 that is developed on the master branch is only compatible to TYPO3 v12

Since Version 2, PHP 7.4 is required.

1.x 2.x 3.x
TYPO3 v12
TYPO3 v11
TYPO3 v10
TYPO3 v9
TYPO3 v8
PHP 8.3
PHP 8.2
PHP 8.1
PHP 8.0
PHP 7.4
PHP 7.3
PHP 7.2

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:

  1. 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.

  1. page = PAGE
  2. page.10 = TWIGTEMPLATE
  3. page.10 {
  4. templateName = example.html.twig
  5. variables {
  6. foo = TEXT
  7. foo.value = Bar!
  8. }
  9. templateRootPaths {
  10. 10 = EXT:cvc_twig/Resources/Private/TwigTemplates
  11. }
  12. dataProcessing {
  13. 10 = TYPO3\CMS\Frontend\DataProcessing\FilesProcessor
  14. 10 {
  15. references.fieldName = image
  16. }
  17. }
  18. }

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: