Twig Components / Methods / current
Note: You are currently reading the documentation for Bolt 5.0. Looking for the documentation for Bolt 5.2 instead?
current
is a Twig filter to check if a given record or menu corresponds to the page being shown in the browser.
Useful for adding 'active' states to menus and such.
{% if page|current %}class="current"{% endif %}
or:
{% if page|current %}
Yes, {{ page.title }} is the current page.
{% else %}
No, you're viewing another page than {{ page.title}}
{% endif %}
Source: Bolt
Edit this page on GitHub
Couldn't find what you were looking for? We are happy to help you in the forum, on Slack or on Github.
Couldn't find what you were looking for? We are happy to help you in the forum, on Slack or on Github.