Skip to content

Commit

Permalink
Merge branch 'master' into refactor-footer-component-to-use-includes-…
Browse files Browse the repository at this point in the history
…facade
  • Loading branch information
caendesilva committed Jul 18, 2022
2 parents f4959b1 + ae444dc commit 92a2b3c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions packages/framework/src/Facades/Includes.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public static function markdown(string $filename, ?string $default = null): ?str
$path = static::path(basename($filename, '.md').'.md');

if (! file_exists($path)) {
return $default;
return $default === null ? null : MarkdownConverter::parse($default);
}

return MarkdownConverter::parse(file_get_contents($path));
Expand All @@ -50,7 +50,7 @@ public static function blade(string $filename, ?string $default = null): ?string
$path = static::path(basename($filename, '.blade.php').'.blade.php');

if (! file_exists($path)) {
return $default;
return $default === null ? null : Blade::render($default);
}

return Blade::render(file_get_contents($path));
Expand Down
8 changes: 4 additions & 4 deletions packages/framework/tests/Feature/IncludesFacadeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ public function test_markdown_returns_rendered_partial()
unlink(Hyde::path('resources/_includes/foo.md'));
}

public function test_markdown_returns_default_value_when_not_found()
public function test_markdown_returns_rendered_default_value_when_not_found()
{
$this->assertNull(Includes::markdown('foo.md'));
$this->assertEquals('default', Includes::markdown('foo.md', 'default'));
$this->assertEquals("<h1>default</h1>\n", Includes::markdown('foo.md', '# default'));
}

public function test_blade_returns_rendered_partial()
Expand All @@ -72,9 +72,9 @@ public function test_blade_returns_rendered_partial()
unlink(Hyde::path('resources/_includes/foo.blade.php'));
}

public function test_blade_returns_default_value_when_not_found()
public function test_blade_returns_rendered_default_value_when_not_found()
{
$this->assertNull(Includes::blade('foo.blade.php'));
$this->assertEquals('default', Includes::blade('foo.blade.php', 'default'));
$this->assertEquals('default', Includes::blade('foo.blade.php', '{{ "default" }}'));
}
}

0 comments on commit 92a2b3c

Please sign in to comment.