Skip to content

Commit

Permalink
Use PHP language identifier
Browse files Browse the repository at this point in the history
  • Loading branch information
bencroker committed Jan 13, 2025
1 parent 756f3e6 commit db3cb2e
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Here’s a trivial example that toggles some backend state using the Blade view
</div>
```

```html
```php
{{-- _datastar/toggle.blade.php --}}

@mergesignals(['enabled' => $signals->enabled ? false : true])
Expand All @@ -72,7 +72,7 @@ Start by reading the [Getting Started](https://data-star.dev/guide/getting_start
When working with signals, note that you can convert a PHP array into a JSON object using the `json_encode` function.

```twig
```php
@php
$signals = ['foo' => 1, 'bar' => 2];
@endphp
Expand All @@ -87,39 +87,39 @@ The `datastar()` helper function is available in Blade views and returns a `Data

Returns a `@get()` action request to render a view at the given path.

```html
```php
{{ datastar()->get('path/to/view') }}
```

#### `datastar()->post()`

Works the same as [`datastar()->get()`](#datastar-get) but returns a `@post()` action request to render a view at the given path. A CSRF token is automatically generated and sent along with the request.

```html
```php
{{ datastar()->post('path/to/view') }}
```

#### `datastar()->put()`

Works the same as [`datastar()->post()`](#datastar-post) but returns a `@put()` action request.

```html
```php
{{ datastar()->put('path/to/view') }}
```

#### `datastar()->patch()`

Works the same as [`datastar()->post()`](#datastar-post) but returns a `@patch()` action request.

```html
```php
{{ datastar()->patch('path/to/view') }}
```

#### `datastar()->delete()`

Works the same as [`datastar()->post()`](#datastar-post) but returns a `@delete()` action request.

```html
```php
{{ datastar()->delete('path/to/view') }}
```

Expand All @@ -129,7 +129,7 @@ Works the same as [`datastar()->post()`](#datastar-post) but returns a `@delete(

Merges one or more fragments into the DOM.

```html
```php
@mergefragments
<div id="new-fragment">New fragment</div>
@endmergefragments
Expand All @@ -139,31 +139,31 @@ Merges one or more fragments into the DOM.

Removes one or more HTML fragments that match the provided selector from the DOM.

```html
```php
@removefragments('#old-fragment')
```

#### `@mergesignals`

Updates the signals with new values.

```html
```php
@mergesignals(['foo' => 1, 'bar' => 2])
```

#### `@removesignals`

Removes signals that match one or more provided paths.

```html
```php
@removesignals(['foo', 'bar'])
```

#### `@executescript`

Executes JavaScript in the browser.

```html
```php
@executescript
alert('Hello, world!');
@endexecutescript
Expand Down

0 comments on commit db3cb2e

Please sign in to comment.