Skip to content

Commit

Permalink
custom style option implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
nzwz committed Jan 20, 2025
1 parent 8f2be61 commit 6ed004c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions framework/helpers/BaseHtml.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Check warning on line 210 in framework/helpers/BaseHtml.php

View check run for this annotation

Codecov / codecov/patch

framework/helpers/BaseHtml.php#L208-L210

Added lines #L208 - L210 were not covered by tests
}

return static::tag('style', $content, $options);
}

Expand Down
7 changes: 7 additions & 0 deletions framework/web/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 6ed004c

Please sign in to comment.