Skip to content

Commit

Permalink
Extended the README to include the Composer installation scenario
Browse files Browse the repository at this point in the history
  • Loading branch information
stansidel committed Aug 25, 2013
1 parent 211949c commit 768fb9b
Show file tree
Hide file tree
Showing 2 changed files with 194 additions and 55 deletions.
126 changes: 99 additions & 27 deletions README.md
Expand Up @@ -13,40 +13,112 @@ This extension allows you to use [Twig](http://twig.sensiolabs.org) templates in
* Yii 1.0 or above

###Installation

####Manual

* Extract the release file under `protected/extensions`.
* [Download](http://twig.sensiolabs.org/installation) and extract all Twig files from `fabpot-Twig-______.zip\fabpot-Twig-______\lib\Twig\` under `protected/vendors/Twig`.
* Add the following to your config file 'components' section:

```php
<?php

'viewRenderer' => array(
'class' => 'ext.ETwigViewRenderer',

// All parameters below are optional, change them to your needs
'fileExtension' => '.twig',
'options' => array(
'autoescape' => true,
),
'extensions' => array(
'My_Twig_Extension',
),
'globals' => array(
'html' => 'CHtml'
),
'functions' => array(
'rot13' => 'str_rot13',
),
'filters' => array(
'jencode' => 'CJSON::encode',
),
// Change template syntax to Smarty-like (not recommended)
'lexerOptions' => array(
'tag_comment' => array('{*', '*}'),
'tag_block' => array('{', '}'),
'tag_variable' => array('{$', '}')
),
),
'viewRenderer' => array(
'class' => 'ext.ETwigViewRenderer',

// Uncomment the following line if twig installed via Composer
//'twigPathAlias' => 'application.vendor.twig.twig.lib.Twig',

// All parameters below are optional, change them to your needs
'fileExtension' => '.twig',
'options' => array(
'autoescape' => true,
),
'extensions' => array(
'My_Twig_Extension',
),
'globals' => array(
'html' => 'CHtml'
),
'functions' => array(
'rot13' => 'str_rot13',
),
'filters' => array(
'jencode' => 'CJSON::encode',
),
// Change template syntax to Smarty-like (not recommended)
'lexerOptions' => array(
'tag_comment' => array('{*', '*}'),
'tag_block' => array('{', '}'),
'tag_variable' => array('{$', '}')
),
),
```

####Via Composer

* Get [Composer](http://getcomposer.org/)
* Create file protected/composer.json if absent:

```json
{
"repositories":[
{
"type":"package",
"package":{
"name":"yiiext/twig-renderer",
"version":"1.1.4",
"source":{
"type":"git",
"url":"https://github.com/yiiext/twig-renderer",
"reference":"v1.1.4"
}
}
}
],
"require":{
"php":">=5.3.0",
"yiisoft/yii": "dev-master",
"twig/twig": "1.*",
"yiiext/twig-renderer":"1.1.*"
}
}
```

* Run `composer update` in protected.
* Add the following to your config file 'components' section:

```php
<?php

'viewRenderer' => array(
'class' => 'application.vendor.yiiext.twig-renderer.ETwigViewRenderer',
'twigPathAlias' => 'application.vendor.twig.twig.lib.Twig',

// All parameters below are optional, change them to your needs
'fileExtension' => '.twig',
'options' => array(
'autoescape' => true,
),
'extensions' => array(
'My_Twig_Extension',
),
'globals' => array(
'html' => 'CHtml'
),
'functions' => array(
'rot13' => 'str_rot13',
),
'filters' => array(
'jencode' => 'CJSON::encode',
),
// Change template syntax to Smarty-like (not recommended)
'lexerOptions' => array(
'tag_comment' => array('{*', '*}'),
'tag_block' => array('{', '}'),
'tag_variable' => array('{$', '}')
),
),
```

###Usage
Expand Down
123 changes: 95 additions & 28 deletions README_RU.md
Expand Up @@ -13,41 +13,108 @@
* Yii 1.0 и выше

###Установка
####Ручная
* Распаковать в `protected/extensions`.
* [Скачать](http://twig.sensiolabs.org/installation) и распаковать все файлы
Twig из `fabpot-Twig-______.zip\fabpot-Twig-______\lib\Twig\` в `protected/vendors/Twig`.
Twig из `fabpot-Twig-______.zip\fabpot-Twig-______\lib\Twig\` в `protected/vendors/Twig`.
* Добавить следующее в файл конфигурации в секцию 'components':

```php
<?php

'viewRenderer' => array(
'class' => 'ext.ETwigViewRenderer',

// Все параметры ниже являются необязательными
'fileExtension' => '.twig',
'options' => array(
'autoescape' => true,
),
'extensions' => array(
'My_Twig_Extension',
),
'globals' => array(
'html' => 'CHtml'
),
'functions' => array(
'rot13' => 'str_rot13',
),
'filters' => array(
'jencode' => 'CJSON::encode',
),
// Пример изменения синтаксиса на Smarty-подобный (не рекомендуется использовать)
'lexerOptions' => array(
'tag_comment' => array('{*', '*}'),
'tag_block' => array('{', '}'),
'tag_variable' => array('{$', '}')
),
),
'viewRenderer' => array(
'class' => 'ext.ETwigViewRenderer',

// Все параметры ниже являются необязательными
'fileExtension' => '.twig',
'options' => array(
'autoescape' => true,
),
'extensions' => array(
'My_Twig_Extension',
),
'globals' => array(
'html' => 'CHtml'
),
'functions' => array(
'rot13' => 'str_rot13',
),
'filters' => array(
'jencode' => 'CJSON::encode',
),
// Пример изменения синтаксиса на Smarty-подобный (не рекомендуется использовать)
'lexerOptions' => array(
'tag_comment' => array('{*', '*}'),
'tag_block' => array('{', '}'),
'tag_variable' => array('{$', '}')
),
),
```

####Через Composer

* Установить [Composer](http://getcomposer.org/).
* Создать файл protected/composer.json, если он отсутствует:

```json
{
"repositories":[
{
"type":"package",
"package":{
"name":"yiiext/twig-renderer",
"version":"1.1.4",
"source":{
"type":"git",
"url":"https://github.com/yiiext/twig-renderer",
"reference":"v1.1.4"
}
}
}
],
"require":{
"php":">=5.3.0",
"yiisoft/yii": "dev-master",
"twig/twig": "1.*",
"yiiext/twig-renderer":"1.1.*"
}
}
```

* Выполнить команду `composer update`.
* Добавить следующее в файл конфигурации в секцию 'components':

```php
<?php

'viewRenderer' => array(
'class' => 'application.vendor.yiiext.twig-renderer.ETwigViewRenderer',
'twigPathAlias' => 'application.vendor.twig.twig.lib.Twig',

// Все параметры ниже являются необязательными
'fileExtension' => '.twig',
'options' => array(
'autoescape' => true,
),
'extensions' => array(
'My_Twig_Extension',
),
'globals' => array(
'html' => 'CHtml'
),
'functions' => array(
'rot13' => 'str_rot13',
),
'filters' => array(
'jencode' => 'CJSON::encode',
),
// Пример изменения синтаксиса на Smarty-подобный (не рекомендуется использовать)
'lexerOptions' => array(
'tag_comment' => array('{*', '*}'),
'tag_block' => array('{', '}'),
'tag_variable' => array('{$', '}')
),
),
```

###Использование
Expand Down

0 comments on commit 768fb9b

Please sign in to comment.