Skip to content

Commit

Permalink
Merge pull request #6 from fabianmichael/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
fabianmichael authored Jul 4, 2024
2 parents 5f01021 + dacd248 commit f1c87e0
Show file tree
Hide file tree
Showing 5 changed files with 1,026 additions and 258 deletions.
20 changes: 18 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,24 @@ You can also use named arguments if you prefer a leaner syntax. Be aware, that t
) ?>>
```

⚠️ If you need XML-compatible attributes, always call `$attributes->toXml()` instead of just echoing the `Attributes` object,
because otherwise all attributes will be converted to lower-case.
Or if all you have is an attributes string, you can also feed the that to the `attributes()` helper:

```php
<?php

// get image dimensions as height="yyy" width="xxx"
$src = 'img.png';
$size = getimagesize($src)[3];

?>

<img <?= attributes($size)->merge([
'src' => $src,
'alt' => '',
]) ?>>
```

⚠️ If you need XML-compatible attributes, always call `$attributes->toXml()` instead of just echoing the `Attributes` object, because otherwise all attributes will be converted to lower-case.

In many cases, you need to set different classes. The `classes()` helper is a nice shortcut for improved readability:

Expand Down
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"homepage": "https://github.com/fabianmichael/kirby-template-attributes",
"license": "MIT",
"type": "kirby-plugin",
"version": "2.2.0",
"version": "2.3.0",
"authors": [
{
"name": "Fabian Michael",
Expand All @@ -20,7 +20,8 @@
"squizlabs/php_codesniffer": "^3.9"
},
"require": {
"getkirby/composer-installer": "^1.2"
"getkirby/composer-installer": "^1.2",
"ext-dom": "*"
},
"autoload": {
"psr-4": {
Expand Down
Loading

0 comments on commit f1c87e0

Please sign in to comment.