Skip to content

Commit

Permalink
Kebab case component names
Browse files Browse the repository at this point in the history
  • Loading branch information
mbardelmeijer committed Nov 23, 2020
1 parent 3975f1a commit 085ec95
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ class Counter extends Component
}
```

## Caveats
- Components with hyphens cannot be called like `{% livewire foo-bar %}` as Twig doesn't allow hyphens like that. We've added a workaround for this by allowing camel case: `{% livewire fooBar %}`

## Todo
- [ ] Implement support for `key` tracking
- [ ] Implement support for preserving child tracking
Expand Down
3 changes: 2 additions & 1 deletion src/LivewireTokenParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Enflow\LivewireTwig;

use Illuminate\Support\Str;
use Twig\Token;
use Twig\TokenParser\AbstractTokenParser;

Expand All @@ -18,7 +19,7 @@ public function parse(Token $token): LivewireNode

$this->parser->getStream()->expect(Token::BLOCK_END_TYPE);

return new LivewireNode($component, $variables, $token->getLine(), $this->getTag());
return new LivewireNode(Str::kebab($component), $variables, $token->getLine(), $this->getTag());
}

public function getTag(): string
Expand Down

0 comments on commit 085ec95

Please sign in to comment.