Skip to content

Commit

Permalink
Update docs for escape parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
romanzipp committed Apr 7, 2019
1 parent c90f1cd commit a5015c6
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 32 deletions.
13 changes: 8 additions & 5 deletions docs/EXAMPLE-APP.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ use romanzipp\Seo\Structs\Meta;
use romanzipp\Seo\Structs\Meta\Charset;
use romanzipp\Seo\Structs\Meta\Description;
use romanzipp\Seo\Structs\Meta\OpenGraph;
use romanzipp\Seo\Structs\Meta\Twitter;
use romanzipp\Seo\Structs\Meta\Viewport;
use romanzipp\Seo\Structs\Title;

Expand Down Expand Up @@ -62,26 +63,28 @@ class SeoServiceProvider extends ServiceProvider

private function bootDefaultStructs()
{
seo()->add(
Title::make()->body(null)
);
seo()->title('Home');
seo()->description('My Description');

seo()->addMany([
Charset::make(),
Viewport::make()->content('width=device-width, initial-scale=1'),
]);

seo()->addMany([
Meta::make()->name('mobile-web-app-capable')->content('yes'),
Meta::make()->name('theme-color')->content('#f03a17'),
Description::make()->content('My Description'),
]);

seo()->addMany([
OpenGraph::make()->property('title')->content('Site-Name'),
OpenGraph::make()->property('description')->content('Description'),
OpenGraph::make()->property('site_name')->content('Site-Name'),
OpenGraph::make()->property('locale')->content('de_DE'),
]);

seo()->add(
Twitter::make()->name('player')->content('http://example.com/player?video=1&t=5', false)
);
}
}
```
Expand Down
48 changes: 21 additions & 27 deletions docs/STRUCTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,42 +130,48 @@ seo()->addMany([
#### Meta name-content Tag

```php
seo()->meta(string $name, $content = null);
seo()->meta(string $name, $content = null, bool $escape = true);
```

... same as ...

```php
seo()->add(
Meta::make()->name(string $name)->content($content = null)
Meta::make()
->name(string $name, bool $escape = true)
->content($content = null, bool $escape = true)
);
```

#### OpenGraph

```php
seo()->og(string $property, $content = null);
seo()->og(string $property, $content = null, bool $escape = true);
```

... same as ...

```php
seo()->add(
OpenGraph::make()->property(string $property)->content($content = null)
OpenGraph::make()
->property(string $property, bool $escape = true)
->content($content = null, bool $escape = true)
);
```

#### Twitter

```php
seo()->twitter(string $name, $content = null);
seo()->twitter(string $name, $content = null, bool $escape = true);
```

... same as ...

```php
seo()->add(
Twitter::make()->name(string $name)->content($content = null)
Twitter::make()
->name(string $name, bool $escape = true)
->content($content = null, bool $escape = true)
);
```

Expand All @@ -191,30 +197,30 @@ romanzipp\Seo\Structs\Meta::make();

```php
romanzipp\Seo\Structs\Meta\AppLink::make()
->property(string $value)
->content(string $value);
->property(string $value, bool $escape = true)
->content(string $value, bool $escape = true);
```

```php
romanzipp\Seo\Structs\Meta\Charset::make()
->charset(string $charset);
->charset(string $charset, bool $escape = true);
```

```php
romanzipp\Seo\Structs\Meta\OpenGraph::make()
->property(string $value)
->content(string $value = null);
->property(string $value, bool $escape = true)
->content(string $value = null, bool $escape = true);
```

```php
romanzipp\Seo\Structs\Meta\Twitter::make()
->name(string $value)
->content(string $value);
->name(string $value, bool $escape = true)
->content(string $value, bool $escape = true);
```

```php
romanzipp\Seo\Structs\Meta\Viewport::make()
->content(string $content);
->content(string $content, bool $escape = true);
```

#### Noscript
Expand All @@ -237,22 +243,10 @@ romanzipp\Seo\Structs\Title::make();

## Escaping

By default, all body and attribute content is escaped. You can change this behavior by setting the `$escape` parameter on both body and attribute setters.
By default, all body and attribute content is escaped via the Laravel [`e()`](https://github.com/illuminate/support/blob/5.8/helpers.php#L607) helper function. You can change this behavior by setting the `$escape` parameter on all attribute setters.

**Use this feature with caution!**

```php
public function body($body, bool $escape = true): self
{
// ...
}

public function attr(string $attribute, $value = null, bool $escape = true): self
{
// ...
}
```

```php
Title::make()->body('Dont \' escape me!', false);
```
Expand Down

0 comments on commit a5015c6

Please sign in to comment.