From a5015c62bcdd9f8d30a82ee63da5f70694d1de57 Mon Sep 17 00:00:00 2001 From: Roman Zipp Date: Sun, 7 Apr 2019 17:50:05 +0200 Subject: [PATCH] Update docs for escape parameter --- docs/EXAMPLE-APP.md | 13 +++++++----- docs/STRUCTS.md | 48 ++++++++++++++++++++------------------------- 2 files changed, 29 insertions(+), 32 deletions(-) diff --git a/docs/EXAMPLE-APP.md b/docs/EXAMPLE-APP.md index ac89c00..e9cfe75 100644 --- a/docs/EXAMPLE-APP.md +++ b/docs/EXAMPLE-APP.md @@ -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; @@ -62,9 +63,8 @@ class SeoServiceProvider extends ServiceProvider private function bootDefaultStructs() { - seo()->add( - Title::make()->body(null) - ); + seo()->title('Home'); + seo()->description('My Description'); seo()->addMany([ Charset::make(), @@ -72,16 +72,19 @@ class SeoServiceProvider extends ServiceProvider ]); 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) + ); } } ``` diff --git a/docs/STRUCTS.md b/docs/STRUCTS.md index 304a3ba..7fde6af 100644 --- a/docs/STRUCTS.md +++ b/docs/STRUCTS.md @@ -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) ); ``` @@ -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 @@ -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); ```