mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-15 05:45:33 +08:00
Allow setting css options per CSS file in AssetBundle::, fixes #10158
This commit is contained in:
@@ -201,6 +201,21 @@ EOF;
|
||||
|
||||
$expected = <<<EOF
|
||||
123<script src="/js/jquery.js"></script>4
|
||||
EOF;
|
||||
$this->assertEquals($expected, $view->renderFile('@yiiunit/data/views/rawlayout.php'));
|
||||
}
|
||||
|
||||
public function testCssOptions()
|
||||
{
|
||||
$view = $this->getView();
|
||||
|
||||
$this->assertEmpty($view->assetBundles);
|
||||
TestAssetCssOptions::register($view);
|
||||
|
||||
$expected = <<<EOF
|
||||
1<link href="/js/default_options.css" rel="stylesheet" media="screen" hreflang="en">
|
||||
<link href="/js/tv.css" rel="stylesheet" media="tv" hreflang="en">
|
||||
<link href="/js/screen_and_print.css" rel="stylesheet" media="screen, print" hreflang="en">234
|
||||
EOF;
|
||||
$this->assertEquals($expected, $view->renderFile('@yiiunit/data/views/rawlayout.php'));
|
||||
}
|
||||
@@ -271,3 +286,15 @@ class TestAssetCircleB extends AssetBundle
|
||||
'yiiunit\\framework\\web\\TestAssetCircleA'
|
||||
];
|
||||
}
|
||||
|
||||
class TestAssetCssOptions extends AssetBundle
|
||||
{
|
||||
public $basePath = '@testWebRoot/js';
|
||||
public $baseUrl = '@testWeb/js';
|
||||
public $css = [
|
||||
'default_options.css',
|
||||
['tv.css', 'media' => 'tv'],
|
||||
['screen_and_print.css', 'media' => 'screen, print']
|
||||
];
|
||||
public $cssOptions = ['media' => 'screen', 'hreflang' => 'en'];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user