diff --git a/app/Providers/TwigProvider.php b/app/Providers/TwigProvider.php index 51537ed..45177eb 100644 --- a/app/Providers/TwigProvider.php +++ b/app/Providers/TwigProvider.php @@ -19,6 +19,7 @@ class TwigProvider ViewFunctions\Config::class, ViewFunctions\Icon::class, ViewFunctions\Markdown::class, + ViewFunctions\ParentDir::class, ViewFunctions\SizeForHumans::class, ]; diff --git a/app/ViewFunctions/ParentDir.php b/app/ViewFunctions/ParentDir.php new file mode 100644 index 0000000..e59366f --- /dev/null +++ b/app/ViewFunctions/ParentDir.php @@ -0,0 +1,25 @@ +filter()->slice(0, -1)->implode('/'); + } +} diff --git a/app/resources/views/components/file.twig b/app/resources/views/components/file.twig index 4b61f43..ab6cb76 100644 --- a/app/resources/views/components/file.twig +++ b/app/resources/views/components/file.twig @@ -1,5 +1,5 @@
diff --git a/app/resources/views/index.twig b/app/resources/views/index.twig index 1161b61..9cd1615 100644 --- a/app/resources/views/index.twig +++ b/app/resources/views/index.twig @@ -20,9 +20,7 @@
{% if not search and not is_root %} - {{ include('components/file.twig', { - parentDir: true - }, with_context = false) }} + {{ include('components/file.twig', { parentDir: true }) }} {% endif %} {% for file in files %} diff --git a/tests/ViewFunctions/ParentTest.php b/tests/ViewFunctions/ParentTest.php new file mode 100644 index 0000000..6f6c0f4 --- /dev/null +++ b/tests/ViewFunctions/ParentTest.php @@ -0,0 +1,16 @@ +container, $this->config); + + $this->assertEquals('foo/bar', $parentDir('foo/bar/baz')); + } +}