Skip to content

Commit

Permalink
Merge pull request #7918 from cakephp/ADmad-patch-1
Browse files Browse the repository at this point in the history
Add example for generating meta tag with CSRF token
  • Loading branch information
markstory authored Sep 16, 2024
2 parents a4849a1 + 16a21af commit c6af97f
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions en/views/helpers/html.rst
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,11 @@ csrfToken The current CSRF token

.. code-block:: php
<?= $this->Html->meta(
echo $this->Html->meta(
'favicon.ico',
'/favicon.ico',
['type' => 'icon']
);
?>
// Output (line breaks added)
// Note: The helper code makes two meta tags to ensure the
// icon is downloaded by both newer and older browsers
Expand All @@ -170,12 +169,11 @@ csrfToken The current CSRF token
rel="shortcut icon"
/>
<?= $this->Html->meta(
echo $this->Html->meta(
'Comments',
'/comments/index.rss',
['type' => 'rss']
);
?>
// Output (line breaks added)
<link
href="http://example.com/comments/index.rss"
Expand All @@ -187,22 +185,24 @@ csrfToken The current CSRF token
This method can also be used to add the meta keywords and
descriptions. Example::

<?= $this->Html->meta(
echo $this->Html->meta(
'keywords',
'enter any meta keyword here'
);
?>
// Output
<meta name="keywords" content="enter any meta keyword here" />

<?= $this->Html->meta(
echo $this->Html->meta(
'description',
'enter any meta description here'
);
?>
// Output
<meta name="description" content="enter any meta description here" />

echo $this->Html->meta('csrfToken');
// The CsrfProtection middleware must be loaded for your application
<meta name="csrf-token" content="CSRF token here" />

In addition to making predefined meta tags, you can create link elements::

<?= $this->Html->meta([
Expand Down

0 comments on commit c6af97f

Please sign in to comment.