From c165a18255817cd7996e90c609e70d14196696e1 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Tue, 19 Dec 2023 12:03:04 +0100 Subject: [PATCH 1/3] Rename local template variable to better match usage --- .../components/docs/documentation-article.blade.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/framework/resources/views/components/docs/documentation-article.blade.php b/packages/framework/resources/views/components/docs/documentation-article.blade.php index 1bacc9e5c42..d2c02ea978a 100644 --- a/packages/framework/resources/views/components/docs/documentation-article.blade.php +++ b/packages/framework/resources/views/components/docs/documentation-article.blade.php @@ -1,20 +1,20 @@ @php - $document = \Hyde\Framework\Features\Documentation\SemanticDocumentationArticle::make($page); + $article = \Hyde\Framework\Features\Documentation\SemanticDocumentationArticle::make($page); @endphp
$document->hasTorchlight()])> + 'torchlight-enabled' => $article->hasTorchlight()])> @yield('content')
- {{ $document->renderHeader() }} + {{ $article->renderHeader() }}
- {{ $document->renderBody() }} + {{ $article->renderBody() }}
- {{ $document->renderFooter() }} + {{ $article->renderFooter() }}
\ No newline at end of file From 4f9464db508a2185e72e16cd13431ee213cfe752 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Thu, 21 Dec 2023 13:00:10 +0100 Subject: [PATCH 2/3] Update documentation article component to support existing variables Allows for them to be passed from a model class, for example. --- .../docs/documentation-article.blade.php | 2 +- .../Feature/Services/HydeSmartDocsTest.php | 22 +++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/packages/framework/resources/views/components/docs/documentation-article.blade.php b/packages/framework/resources/views/components/docs/documentation-article.blade.php index d2c02ea978a..328f370982d 100644 --- a/packages/framework/resources/views/components/docs/documentation-article.blade.php +++ b/packages/framework/resources/views/components/docs/documentation-article.blade.php @@ -1,5 +1,5 @@ @php - $article = \Hyde\Framework\Features\Documentation\SemanticDocumentationArticle::make($page); + $article ??= \Hyde\Framework\Features\Documentation\SemanticDocumentationArticle::make($page); @endphp
assertStringContainsString('

Hello world.

', $rendered); } + public function test_the_documentation_article_view_with_existing_variable() + { + $rendered = view('hyde::components.docs.documentation-article', [ + 'page' => $page = $this->makePage(), + 'article' => new class($page) extends SemanticDocumentationArticle + { + public function __construct(DocumentationPage $page) + { + parent::__construct($page); + } + + public function renderHeader(): HtmlString + { + return new HtmlString('

Custom Header

'); + } + }, + ])->render(); + + $this->assertStringContainsString('

Custom Header

', $rendered); + $this->assertStringContainsString('

Hello world.

', $rendered); + } + protected function makeArticle(string $sourceFileContents = "# Foo\n\nHello world."): SemanticDocumentationArticle { $this->file('_docs/foo.md', $sourceFileContents); From 2f07b97d3eae1a0f181b0daae646e980d73c54e1 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Sat, 23 Dec 2023 13:05:47 +0100 Subject: [PATCH 3/3] Update documentation article component to support existing variables Allows for them to be passed from a model class, for example. --- RELEASE_NOTES.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index e3d1b60364c..1b56f37fc74 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -13,7 +13,8 @@ This serves two purposes: - for new features. ### Changed -- for changes in existing functionality. +- Renamed local template variable `$document` to `$article` to better match the usage in https://github.com/hydephp/develop/pull/1506 +- Updated semantic documentation article component to support existing variables in https://github.com/hydephp/develop/pull/1506 ### Deprecated - for soon-to-be removed features.