InlineCss.php 756 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. /**
  3. * @package Grav\Common\Assets
  4. *
  5. * @copyright Copyright (C) 2015 - 2019 Trilby Media, LLC. All rights reserved.
  6. * @license MIT License; see LICENSE file for details.
  7. */
  8. namespace Grav\Common\Assets;
  9. use Grav\Common\Utils;
  10. class InlineCss extends BaseAsset
  11. {
  12. public function __construct(array $elements = [], $key = null)
  13. {
  14. $base_options = [
  15. 'asset_type' => 'css',
  16. 'position' => 'after'
  17. ];
  18. $merged_attributes = Utils::arrayMergeRecursiveUnique($base_options, $elements);
  19. parent::__construct($merged_attributes, $key);
  20. }
  21. public function render()
  22. {
  23. return '<style' . $this->renderAttributes(). ">\n" . trim($this->asset) . "\n</style>\n";
  24. }
  25. }