diff --git a/framework/helpers/BaseHtml.php b/framework/helpers/BaseHtml.php index ff81df22752..3d7bc17d772 100644 --- a/framework/helpers/BaseHtml.php +++ b/framework/helpers/BaseHtml.php @@ -205,6 +205,11 @@ public static function endTag($name) */ public static function style($content, $options = []) { + $view = Yii::$app->getView(); + if ($view instanceof \yii\web\View && !empty($view->styleOptions)) { + $options = array_merge($view->styleOptions, $options); + } + return static::tag('style', $content, $options); } diff --git a/framework/web/View.php b/framework/web/View.php index 04aa5069b7c..ccc98812d9e 100644 --- a/framework/web/View.php +++ b/framework/web/View.php @@ -120,6 +120,13 @@ class View extends \yii\base\View * @see registerCssFile() */ public $cssFiles = []; + + /** + * @since 2.0.52 + * @var array the style tag options. + */ + public $styleOptions = []; + /** * @var array the registered JS code blocks * @see registerJs()