PHPackages                             andrew72ru/bitrix-twig - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. andrew72ru/bitrix-twig

AbandonedLibrary

andrew72ru/bitrix-twig
======================

Twig renderer for bitrix framework

v0.1.4(7y ago)1149MITPHP

Since Jun 6Pushed 6y agoCompare

[ Source](https://github.com/andrew72ru/bitrix-twig)[ Packagist](https://packagist.org/packages/andrew72ru/bitrix-twig)[ RSS](/packages/andrew72ru-bitrix-twig/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (3)Versions (6)Used By (0)

BITRIX/TWIG
===========

[](#bitrixtwig)

> Module for rendering twig templates in bitrix framework

[rus](README_RU.md)

Intro
-----

[](#intro)

Bitrix framework allows render content with third-party template engines, in particular, [twig](https://twig.symfony.com).

To implement this, bitrix required a global (*sic!*) array `$arCustomTemplateEngines` with next structure:

```
$arCustomTemplateEngines['twig'] = [
    'templateExt' => ['twig', 'html.twig'],
    'function'    => 'renderTwigTemplate'
];
```

The `templateExt` key describes extensions of template files, and in `function` key of this array contains the global (*sic!*) function name, which implement the render of template.

Also, function must instantiate the template engine class and echo (yes, fucking echo, not return!) the result of rendering.

If you even feel headache because of this, wait a minute, **this is not all**.

Installation
------------

[](#installation)

You **MUST** use the composer autoloader in application init. You site **MUST** use utf-8 codepage.

To install module, simple run

```
composer require andrew72ru/bitrix-twig

```

Module will be stored in you `vendor`, register it classes and functions.

Configuration
-------------

[](#configuration)

Default configuration:

```
'debug' => false,
'charset' => 'utf-8',
'cache' => $_SERVER['DOCUMENT_ROOT'] . '/bitrix/cache/twig',
'auto_reload' => $this->request->get('clear_cache') ? 'Y' === strtoupper($this->request->get('clear_cache')) : false,
'autoescape' => false,
```

You may override or extend this configuration in `bitrix/.settings.php` file. The configuration key is `twigRenderer`. You config may be like this:

```
// bitrix/.settings.php
