Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
hirasso committed Aug 7, 2024
1 parent a48b1cf commit 3288cbb
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ composer require hirasso/attr

## Usage

You define your attributes in an associative way:
### `attr()`

Define your attributes in an associative way:

```php
<button <?= attr([
Expand Down Expand Up @@ -40,3 +42,16 @@ You define your attributes in an associative way:
Click Me!
</button>
```

## `jsonInAttr()`

Render JSON so that it is safe to be used inside an HTMLElement attribute:

```php
/** Example: render an attribute to be used by Alpine.js */
echo attr([
'x-data' => jsonInAttr([
'open' => 'true',
])
])
```

0 comments on commit 3288cbb

Please sign in to comment.