Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support using HTML includes to set head and script HTML #600

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion resources/views/layouts/head.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@
@endif

{{-- If the user has defined any custom head tags, render them here --}}
{!! config('hyde.head') !!}
{!! config('hyde.head') !!}
{!! Includes::html('head') !!}
1 change: 1 addition & 0 deletions resources/views/layouts/scripts.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ function toggleTheme() {

{{-- If the user has defined any custom scripts, render them here --}}
{!! config('hyde.scripts') !!}
{!! Includes::html('scripts') !!}
7 changes: 7 additions & 0 deletions tests/Unit/Views/HeadComponentViewTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@ public function testCanAddHeadHtmlFromConfigHook()
$this->assertStringContainsString('<meta name="custom-hook" content="foo">', $this->renderTestView());
}

public function testCanAddHeadHtmlFromHtmlInclude()
{
$this->file('resources/includes/head.html', '<meta name="custom-include" content="foo">');

$this->assertStringContainsString('<meta name="custom-include" content="foo">', $this->renderTestView());
}

protected function escapeIncludes(string $contents): string
{
return str_replace('@include', '@@include', $contents);
Expand Down
9 changes: 8 additions & 1 deletion tests/Unit/Views/ScriptsComponentViewTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,20 @@ public function test_component_uses_relative_path_to_app_js_file_for_nested_page
Filesystem::unlink('_media/app.js');
}

public function testCanAddHeadHtmlFromConfigHook()
public function testCanAddScriptsHtmlFromConfigHook()
{
config(['hyde.scripts' => '<script src="custom-hook.js"></script>']);

$this->assertStringContainsString('<script src="custom-hook.js"></script>', $this->renderTestView());
}

public function testCanAddScriptsHtmlFromHtmlInclude()
{
$this->file('resources/includes/scripts.html', '<script src="html-include.js"></script>');

$this->assertStringContainsString('<script src="html-include.js"></script>', $this->renderTestView());
}

public function test_scripts_can_be_pushed_to_the_component_scripts_stack()
{
view()->share('routeKey', '');
Expand Down
Loading