Skip to content

Commit

Permalink
Merge pull request #20 from ARCANEDEV/feature-html_string
Browse files Browse the repository at this point in the history
Adding the HtmlString class to render the seo tags without escaping
  • Loading branch information
arcanedev-maroc authored Dec 15, 2016
2 parents fdc2b3d + 545d31d commit 2fc2cce
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 2 deletions.
14 changes: 12 additions & 2 deletions _docs/4-Usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -1115,13 +1115,23 @@ For example, if you want to render all the tags inside your blade view:

```blade
<head>
{{ seo_helper()->render() }}
{!! seo_helper()->render() !!}
</head>
```

##### OR

```blade
<head>
{{ seo_helper()->renderHtml() }}
</head>
```

You can also do stuff like this (rendering the tags without the opengraph and twitter card):

```blade
<head>
{{ seo_helper()->meta()->render() }}
{!! seo_helper()->meta()->render() !!}
</head>
```

Expand Down
7 changes: 7 additions & 0 deletions _docs/5-API.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
7 changes: 7 additions & 0 deletions src/Contracts/SeoHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
12 changes: 12 additions & 0 deletions src/SeoHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
9 changes: 9 additions & 0 deletions tests/SeoHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down

0 comments on commit 2fc2cce

Please sign in to comment.