I am use Yii2 advanced with Twig integration. I need include js and css files to head block and use AssetBundle for this.
If I use POS_BEGIN or POS_END it's work. Js and css load to page in current position. But if I set position as POS_HEAD render ignore this and no load files to page.
Please help. What am I doing wrong?
My AssetBundle
namespace frontend\assets;
use yii\web\AssetBundle;
class YandexAsset extends AssetBundle
{
public $basePath = '@webroot';
public $baseUrl = '@web';
public $css = [
'/css/map.css'
];
public $js = [
'js/map.js',
'js/test.js'
];
public $depends = [
'yii\web\YiiAsset',
'yii\bootstrap\BootstrapAsset',
];
public $jsOptions = [ 'position' => \yii\web\View::POS_HEAD ];
}
And connect in Twig template
{{ use('frontend/assets/YandexAsset')}}
{{ register_yandex_asset() }}