Skip to content

Commit

Permalink
Add wrapperClass property
Browse files Browse the repository at this point in the history
  • Loading branch information
bencroker committed Feb 12, 2024
1 parent c930b29 commit b8e8397
Show file tree
Hide file tree
Showing 5 changed files with 232 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- Added recommendations to the Blitz cache utility.
- Added the user that runs controller actions to log messages.
- Added an expiry date column to pages and elements in the Blitz Cache utility ([#615](https://github.com/putyourlightson/craft-blitz/issues/615)).
- Added a `wrapperClass` property to the `VariableConfigModel` class ([#620](https://github.com/putyourlightson/craft-blitz/issues/620)).
- Added new console commands for clearing, generating and purging the cache: `blitz/cache/clear-site`, `blitz/cache/clear-tagged`, `blitz/cache/clear-urls`, `blitz/cache/generate-site`, `blitz/cache/generate-tagged`, `blitz/cache/generate-urls`, `blitz/cache/purge-site`, `blitz/cache/purge-tagged`, `blitz/cache/purge-urls`.

### Changed
Expand Down
7 changes: 6 additions & 1 deletion src/models/VariableConfigModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ class VariableConfigModel extends Model
*/
public string $wrapperElement = 'span';

/**
* @var string Specifies the class to add to the wrapper element.
*/
public string $wrapperClass = '';

/**
* @var string Specifies the placeholder content.
*/
Expand All @@ -50,7 +55,7 @@ class VariableConfigModel extends Model
protected function defineRules(): array
{
return [
[['requestType', 'wrapperElement', 'placeholder', 'property'], 'string'],
[['requestType', 'wrapperElement', 'wrapperClass', 'placeholder', 'property'], 'string'],
[['requestType'], 'in', 'range' => [self::AJAX_REQUEST_TYPE, self::INCLUDE_REQUEST_TYPE]],
];
}
Expand Down
2 changes: 1 addition & 1 deletion src/variables/BlitzVariable.php
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ private function _getScript(string $uri, array $params, VariableConfigModel $con
];

$output = Html::tag($config->wrapperElement, $config->placeholder, [
'class' => 'blitz-inject',
'class' => $config->wrapperClass . ' blitz-inject',
'id' => 'blitz-inject-' . $id,
'data' => $data,
]);
Expand Down
Loading

0 comments on commit b8e8397

Please sign in to comment.