Skip to content
This repository was archived by the owner on Jan 9, 2024. It is now read-only.

Commit fa40c18

Browse files
committed
wip
1 parent bb25ce0 commit fa40c18

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,26 @@ TagHelper::helper(CustomTagHelper::class);
6969

7070
Since you only register the class name of the custom tag helper, you can use dependency injection inside of your custom helper class.
7171

72+
### Binding your helper to HTML elements and attributes
73+
74+
In your custom tag helper, you can use the `$targetAttribute` and `$targetElement` properties to specify which HTML element (`div`, `form`, `a`, etc.) and which attributes (`<div custom="value />`, `<form method="post">`, etc.) you want to bind this helper to.
75+
76+
If you do not provide a `targetElement` on your own, this package will use a `*` as a wildcard in order to target **all** elements with a specific attribute, like this:
77+
78+
```php
79+
class CustomTagHelper extends Helper
80+
{
81+
protected $targetAttribute = 'my-attribute';
82+
83+
// ...
84+
85+
}
86+
```
87+
88+
This tag helper would be called for every HTML element that has a `my-attribute` attribute.
89+
90+
### Manipulating DOM Elements
91+
7292
## Built-In Helpers
7393

7494

0 commit comments

Comments
 (0)