Skip to content

Commit

Permalink
Fix styling
Browse files Browse the repository at this point in the history
  • Loading branch information
nickpoulos authored and actions-user committed Jun 12, 2021
1 parent 44ad3b0 commit d7f68ba
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
2 changes: 2 additions & 0 deletions src/SvelteDirectServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public function loadBladePreCompiler() : void
public function precompiler(string $viewTemplateCode)
{
$tagsToLoad = $this->findSvelteComponentTagsInBlade($viewTemplateCode);

return $viewTemplateCode . $this->appendPushDirective($tagsToLoad);
}

Expand All @@ -93,6 +94,7 @@ public function findSvelteComponentTagsInBlade(string $view) : array
$tagPattern = implode('|', array_keys($this->manifest));
$pattern = "/(?<=<)\s*(?:{$tagPattern})(?=\s|>|\/)+/";
preg_match_all($pattern, $view, $matches);

return array_intersect(array_keys($this->manifest), array_unique($matches[0]));
}

Expand Down
14 changes: 7 additions & 7 deletions tests/SvelteDirectTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class SvelteDirectTest extends TestCase
*/
protected array $testManifest = [
'test-tag' => '/js/TestTag.js',
'nick-poulos' => '/js/NickPoulos.js'
'nick-poulos' => '/js/NickPoulos.js',
];

/**
Expand Down Expand Up @@ -203,23 +203,23 @@ public function bladeTemplateCodeDataProvider() : array
return [
"Regular Style Tags" => [
$expectedResultWhenFound,
$regularStyleTags
$regularStyleTags,
],
"Single Closing Style Tags" => [
$expectedResultWhenFound,
$singleClosingStyleTags
$singleClosingStyleTags,
],
"Nested Regular Style Tags" => [
$expectedResultWhenFound,
$nestedRegularStyleTags
$nestedRegularStyleTags,
],
"Nested Single Closing Style Tags" => [
$expectedResultWhenFound,
$nestedSingleClosingStyleTags
$nestedSingleClosingStyleTags,
],
"Broken Tag That Is Close" => [
$expectedResultWhenNotFound,
$brokenTagsWithCloseName
$brokenTagsWithCloseName,
],
];
}
Expand All @@ -232,7 +232,7 @@ protected function buildTestManifestCode(array $testManifest) : string
{
$result = "<?php return [" . PHP_EOL;

array_walk($testManifest, function(string $jsFile, string $tag) use(&$result) {
array_walk($testManifest, function (string $jsFile, string $tag) use (&$result) {
$result .= "'" . $tag . "' => '" . $jsFile . "'," . PHP_EOL;
});

Expand Down

0 comments on commit d7f68ba

Please sign in to comment.