diff --git a/_docs/4-Usage.md b/_docs/4-Usage.md index efe9979..fa17df1 100644 --- a/_docs/4-Usage.md +++ b/_docs/4-Usage.md @@ -1115,13 +1115,23 @@ For example, if you want to render all the tags inside your blade view: ```blade - {{ seo_helper()->render() }} + {!! seo_helper()->render() !!} ``` + +##### OR + +```blade + + {{ seo_helper()->renderHtml() }} + +``` + You can also do stuff like this (rendering the tags without the opengraph and twitter card): + ```blade - {{ seo_helper()->meta()->render() }} + {!! seo_helper()->meta()->render() !!} ``` diff --git a/_docs/5-API.md b/_docs/5-API.md index 287757c..5a2aad6 100644 --- a/_docs/5-API.md +++ b/_docs/5-API.md @@ -844,6 +844,13 @@ interface SeoHelper extends Renderable | Main Functions | ------------------------------------------------------------------------------------------------ */ + /** + * Render all seo tags with HtmlString object. + * + * @return \Illuminate\Support\HtmlString + */ + public function renderHtml(); + /** * Enable the OpenGraph. * diff --git a/src/Contracts/SeoHelper.php b/src/Contracts/SeoHelper.php index 83b8331..cefc3a7 100644 --- a/src/Contracts/SeoHelper.php +++ b/src/Contracts/SeoHelper.php @@ -110,6 +110,13 @@ public function setSiteName($siteName); | Main Functions | ------------------------------------------------------------------------------------------------ */ + /** + * Render all seo tags with HtmlString object. + * + * @return \Illuminate\Support\HtmlString + */ + public function renderHtml(); + /** * Enable the OpenGraph. * diff --git a/src/SeoHelper.php b/src/SeoHelper.php index f342ba9..cf7c3b3 100644 --- a/src/SeoHelper.php +++ b/src/SeoHelper.php @@ -228,6 +228,18 @@ public function render() ])); } + /** + * Render all seo tags with HtmlString object. + * + * @return \Illuminate\Support\HtmlString + */ + public function renderHtml() + { + return new \Illuminate\Support\HtmlString( + $this->render() + ); + } + /** * Render the tag. * diff --git a/tests/SeoHelperTest.php b/tests/SeoHelperTest.php index 891e7c3..9e5d3cf 100644 --- a/tests/SeoHelperTest.php +++ b/tests/SeoHelperTest.php @@ -190,6 +190,15 @@ public function it_can_render_all() $this->assertNotEmpty($output); } + /** @test */ + public function it_can_render_all_with_html_string_object() + { + $output = $this->seoHelper->renderHtml(); + + $this->assertInstanceOf(\Illuminate\Support\HtmlString::class, $output); + $this->assertNotEmpty($output->toHtml()); + } + /** @test */ public function it_can_enable_and_disable_open_graph() {