Skip to content

Commit 913cc07

Browse files
committed
Housekeeping, better README
1 parent 015cfae commit 913cc07

File tree

4 files changed

+1525
-1413
lines changed

4 files changed

+1525
-1413
lines changed

LICENSE.md renamed to LICENSE

File renamed without changes.

README.md

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,22 @@
22

33
**Better attribute API for snippets and templates**
44

5-
This plugin brings [Vue.js](https://vuejs.org)/[Laravel-Blade](https://laravel.com/docs/9.x/blade#components)-like attribute composition to the templates of your [Kirby](https://getkirby.com) yproject. This is an exploration in search of better HTML attribute handling for nested snippets and components.
6-
7-
**⚠️ Work-in-progress, use at your own risk ⚠️**
8-
5+
This plugin brings [Vue.js](https://vuejs.org)/[Laravel-Blade](https://laravel.com/docs/9.x/blade#components)-like attribute composition to the templates of your [Kirby project](https://getkirby.com). This is an exploration in search of better HTML attribute handling for nested snippets and components.
96

107
## Requirements
118

12-
- Kirby 3.8
9+
- Kirby 3.8+
1310
- PHP 8.1 (because of [Enumeration](https://www.php.net/manual/en/language.types.enumerations.php) support)
1411

1512
## Installation
1613

17-
During this early development stage, installation only works via composer:
14+
The recommended is installation via composer.
1815

1916
```
2017
composer require fabianmichael/kirby-template-attributes
2118
```
2219

23-
Alternatively, if you want to contribute to the development of this plugin, you can install it via submodule or clone this repository and use it as a local composer dependency.
20+
Alternatively, you can also [download the plugin](https://github.com/fabianmichael/kirby-template-attributes/archive/main.zip) and install it manually by copying it to the `site/plugins/` folder of your website.
2421

2522
## Usage
2623

@@ -37,14 +34,18 @@ Use the `attributes()` helper for generating a string of attributes:
3734
You can also use named arguments if you prefer a leaner syntax. Be aware, that this only works as long as you don’t have dashes in your attribute names:
3835

3936
```php
40-
<svg <?= attributes(
37+
<img <?= attributes(
4138
class: 'icon',
4239
width: 16,
4340
height: 16,
44-
viewBox: '0 0 16 16',
45-
) ?>>[…]</svg>
41+
src: $image->url(),
42+
alt: 'The funniest donkey ever!',
43+
) ?>>
4644
```
4745

46+
⚠️ If you need XML-compatible attributes, always call `$attributes->toXml()` instead of just echoing the `Attributes` object,
47+
because otherwise all attributes will be converted to lower-case.
48+
4849
In many cases, you need to set different classes. The `classes()` helper is a nice shortcut for improved readability:
4950

5051
```php
@@ -88,16 +89,13 @@ The `classes()` helper is pretty flexible and also accepts multiple paramaters,
8889
]) ?>
8990
```
9091

91-
## Custom merge strategies
92-
93-
- Custom merge strategies for arbitrary attributes
94-
95-
9692
## Before/After
9793

94+
You can set `$before` and `$after`, just like for Kirby’s `Html::attr()` helper by using the corresponding methods:
95+
9896
```
99-
->before()
100-
->after()
97+
attributes(class: 'foo')->before(' ');
98+
attributes(class: 'foo')->after(' ');
10199
```
102100

103101
## Examples
@@ -164,3 +162,8 @@ This is already cool and makes working with attributes for snippets much easier,
164162
]) ?>
165163
</nav>
166164
```
165+
166+
167+
## License
168+
169+
MIT (but you are highly encouraged to **[❤️ sponsor me](https://github.com/sponsors/fabianmichael)**, if this piece of software helps you to pay your bills).

composer.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,22 @@
33
"description": "Better HTML attribute handling for your snippets and templates.",
44
"license": "MIT",
55
"type": "kirby-plugin",
6-
"version": "1.2.2",
6+
"version": "1.3.0",
77
"authors": [
88
{
99
"name": "Fabian Michael",
1010
"email": "hallo@fabianmichael.de"
1111
}
1212
],
13+
"require-dev": {
14+
"friendsofphp/php-cs-fixer": "^3.13",
15+
"phpunit/phpunit": "^9",
16+
"phpmd/phpmd" : "@stable",
17+
"vimeo/psalm": "^5.1",
18+
"getkirby/cms": "^3.9"
19+
},
1320
"require": {
14-
"getkirby/composer-installer": "^1.2",
15-
"getkirby/cms": "^3.8"
21+
"getkirby/composer-installer": "^1.2"
1622
},
1723
"autoload": {
1824
"psr-4": {
@@ -41,11 +47,5 @@
4147
"extra": {
4248
"kirby-cms-path": false,
4349
"installer-name": "template-attributes"
44-
},
45-
"require-dev": {
46-
"friendsofphp/php-cs-fixer": "^3.13",
47-
"phpunit/phpunit": "^9",
48-
"phpmd/phpmd" : "@stable",
49-
"vimeo/psalm": "^5.1"
5050
}
5151
}

0 commit comments

Comments
 (0)