yiisoft/yii2-twig — pull request #4 by ofat (2014-05-21 16:11:33+00:00)
Title: support for php namespaces, static calls and yii widgets

Here is example of using:

in yii we do:
```php

...
'My Company',
'brandUrl' => Yii::$app->homeUrl,
'options' => [
'class' => 'navbar-inverse navbar-fixed-top',
],
]);
...
echo Nav::widget([
'options' => ['class' => 'navbar-nav navbar-right'],
'items' => [...],
]);
NavBar::end();
?>

$this->params['breadcrumbs']
]) ?>

```

With these functions we can do:

```php
{{ use([
'yii\\bootstrap\\Nav',
'yii\\bootstrap\\NavBar',
'frontend\\assets\\AppAsset',
'frontend\\widgets\\Alert'
]) }}
{{ static('AppAsset', 'register', this) }}
...
{{ widget_begin('NavBar', { brandLabel: app.name, brandUrl: app.homeUrl, options: { class: 'navbar-inverse navbar-fixed-top' } }) }}
...
{{ widget('Nav', {options: { class: 'navbar-nav navbar-right' }, items: ...) }}
...
{{ widget_end('NavBar') }}
...

{{ widget('yii\\widgets\\Breadcrumbs', {links: this.params['breadcrumbs']}) }}

{{ widget('Alert') }}

```

Also we can define namespaces globally in config files:

```php
'namespaces' => [
'\yii\bootstrap\NavBar',
],
```