Skip to content

Commit

Permalink
Tweak wording and example
Browse files Browse the repository at this point in the history
  • Loading branch information
mbardelmeijer committed Oct 13, 2020
1 parent 952afb3 commit 2a957fd
Showing 1 changed file with 22 additions and 19 deletions.
41 changes: 22 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,25 @@ If you're using another configuration, you may wish to register the extension ma
This package only provides a wrapper for the `@livewireScripts`, `@livewireStyles` & `@livewire` calls. Everything else under the hood is powered by `livewire/livewire`.
You can register your Livewire components like normal.

## Example
In the head
```twig
{{ livewireStyles() }}
## Installation

{{ livewireScripts() }}
Add the following tags in the `head` tag, and before the end `body` tag in your template.

```twig
<html>
<head>
...
{{ livewireStyles() }}
</head>
<body>
...
{{ livewireScripts() }}
</body>
</html>
```

In the body
In your body you may include the component like:

```twig
{# The Twig version of '@livewire' #}
{% livewire counter %}
Expand All @@ -39,15 +49,18 @@ In the body
{% livewire counter with {'count': 3} %}
```

In resources/views/livewire/counter.twig
### Example

Add the following to `resources/views/livewire/counter.twig`
```twig
<div>
<div wire:click="add">+</div>
<div>{{ count }}</div>
<div wire:click="subtract">-</div>
</div>
```
In app/Http/Livewire/Counter.php

Add the following to `app/Http/Livewire/Counter.php`
```php
<?php

Expand All @@ -57,12 +70,7 @@ use Livewire\Component;

class Counter extends Component
{
public $count;

public function mount($count = 1)
{
$this->count = $count;
}
public int $count = 1;

public function add()
{
Expand All @@ -73,11 +81,6 @@ class Counter extends Component
{
$this->count--;
}

public function render()
{
return view('livewire.counter');
}
}
```

Expand Down

0 comments on commit 2a957fd

Please sign in to comment.