Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add example for generating meta tag with CSRF token #7918

Merged
merged 1 commit into from
Sep 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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