Skip to content

Commit

Permalink
Fix styling
Browse files Browse the repository at this point in the history
  • Loading branch information
mbardelmeijer authored and github-actions[bot] committed Sep 22, 2023
1 parent 6f7eb92 commit 7a3f590
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 12 deletions.
4 changes: 3 additions & 1 deletion src/LivewireExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@

use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Blade;
use Livewire\Mechanisms\FrontendAssets\FrontendAssets;
use Twig\Extension\AbstractExtension;
use Twig\TwigFunction;
use Livewire\Mechanisms\FrontendAssets\FrontendAssets;

class LivewireExtension extends AbstractExtension
{
protected Collection $calls;

protected array $dirs = [
'livewireScripts',
'livewireScriptConfig',
Expand All @@ -24,6 +25,7 @@ public function callDirective(string $directive, array $args = []): string
$call = $directives[$directive] ?? null;

$r = call_user_func_array($call, $args);

return "?> $r <?php\n";
}

Expand Down
10 changes: 6 additions & 4 deletions src/LivewireTokenParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public function parse(Token $token)
return (match ($type) {
'this' => function () use ($stream, $lineno) {
$stream->expect(Token::BLOCK_END_TYPE); // Expect the end block

return new ThisNode([], [], $lineno, $this->getTag());
},

Expand All @@ -54,14 +55,14 @@ public function parse(Token $token)
$stream->expect(Token::BLOCK_END_TYPE);

// Parse the body until the 'endpersist' tag.
$body = $this->parser->subparse(function (Token $token) use ($stream) {
$body = $this->parser->subparse(function (Token $token) {
return $token->test('livewire');
}, true);

// Now, since we know we're at a 'livewire.' token, we should expect the 'endpersist' after it.
$stream->expect(Token::PUNCTUATION_TYPE, '.');

if (!$stream->test(Token::NAME_TYPE, 'endpersist')) {
if (! $stream->test(Token::NAME_TYPE, 'endpersist')) {
throw new SyntaxError('Expected the "endpersist" tag.', $stream->getCurrent()->getLine(), $stream->getSourceContext());
}

Expand Down Expand Up @@ -95,15 +96,16 @@ public function parse(Token $token)
$stream->expect(Token::BLOCK_END_TYPE); // Expect the end block

$attrs = ['variables' => $variables, 'key' => $key];

return new LivewireNode($component, $attrs, $lineno, $this->getTag());
},

default => fn() => throw new SyntaxError(sprintf('Unexpected token after "livewire.". Expected %s but got "%s".', implode(' or ', $this->types), $type), $lineno, $stream->getSourceContext()),
default => fn () => throw new SyntaxError(sprintf('Unexpected token after "livewire.". Expected %s but got "%s".', implode(' or ', $this->types), $type), $lineno, $stream->getSourceContext()),
})();
}

public function getTag(): string
{
return 'livewire';
}
}
}
3 changes: 0 additions & 3 deletions src/LivewireTwigServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@

namespace Enflow\LivewireTwig;

use Illuminate\Foundation\Application;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\View;
use Illuminate\Support\Facades\Blade;

class LivewireTwigServiceProvider extends ServiceProvider
{
Expand Down
2 changes: 1 addition & 1 deletion src/Nodes/EntangleNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class EntangleNode extends Node
{
public function compile(Compiler $compiler)
{
$livewire = new NameExpression("__livewire", $this->lineno);
$livewire = new NameExpression('__livewire', $this->lineno);

$compiler
->write('$__livewire = ')->subcompile($livewire)->raw(";\n")
Expand Down
2 changes: 1 addition & 1 deletion src/Nodes/LivewireNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function compile(Compiler $compiler)
$component = $this->getAttribute('component');
$expr = $this->getNode('variables');
$key = $this->getNode('key');
$hasKey = !$key->hasAttribute('value') || $key->getAttribute('value') !== '';
$hasKey = ! $key->hasAttribute('value') || $key->getAttribute('value') !== '';

$compiler
->write('$_name = ')->subcompile($component)->raw(";\n")
Expand Down
2 changes: 1 addition & 1 deletion src/Nodes/ThisNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class ThisNode extends Node
{
public function compile(Compiler $compiler)
{
$livewire = new NameExpression("__livewire", $this->lineno);
$livewire = new NameExpression('__livewire', $this->lineno);

$compiler
->write('$_instance = ')->subcompile($livewire)->raw(";\n")
Expand Down
2 changes: 1 addition & 1 deletion tests/RenderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,4 +142,4 @@ public function render()
{
return view('components.persist');
}
}
}

0 comments on commit 7a3f590

Please sign in to comment.