public function current($content)
    {
        /** @var Request $request */
        $request = $this->requestStack->getCurrentRequest();
        $requestUri = $request->getRequestUri();
        $routeParams = $request->get('_route_params');

        // If passed a string, and it is in the route.
        if (is_string($content) && in_array($content, $routeParams)) {
            return true;
        }

        if (is_array($content)) {
            $linkToCheck = isset($content['link']) ? $content['link'] : null;
        } elseif ($content instanceof \Bolt\Legacy\Content) {
            $linkToCheck = $content->link();
        } else {
            $linkToCheck = (string) $content;
        }

        // check against Request Uri
        if ($requestUri === $linkToCheck) {
            return true;
        }

        // No contenttypeslug or slug -> not 'current'
        if (empty($routeParams['contenttypeslug']) || empty($routeParams['slug'])) {
            return false;
        }

        // check against simple content.link
        if ('/' . $routeParams['contenttypeslug'] . '/' . $routeParams['slug'] === $linkToCheck) {
            return true;
        }

        if (!$content instanceof \Bolt\Legacy\Content || !property_exists($content, 'contenttype')) {
            return false;
        }

        // if the current requested page is for the same slug or singularslug.
        $ct = $content->contenttype;
        if ($routeParams['contenttypeslug'] === $ct['slug'] || $routeParams['contenttypeslug'] === $ct['singular_slug']) {
            // …and the slugs should match.
            return $routeParams['slug'] === $content['slug'];
        }

        return false;
    }
public function current($content)
    {
        /** @var Request $request */
        $request = $this->requestStack->getCurrentRequest();
        $requestUri = $request->getRequestUri();
        $routeParams = $request->get('_route_params');

        // If passed a string, and it is in the route.
        if (is_string($content) && in_array($content, $routeParams)) {
            return true;
        }

        if (is_array($content)) {
            $linkToCheck = isset($content['link']) ? $content['link'] : null;
        } elseif ($content instanceof \Bolt\Legacy\Content) {
            $linkToCheck = $content->link();
        } else {
            $linkToCheck = (string) $content;
        }

        // check against Request Uri
        if ($requestUri === $linkToCheck) {
            return true;
        }

        // No contenttypeslug or slug -> not 'current'
        if (empty($routeParams['contenttypeslug']) || empty($routeParams['slug'])) {
            return false;
        }

        // check against simple content.link
        if ('/' . $routeParams['contenttypeslug'] . '/' . $routeParams['slug'] === $linkToCheck) {
            return true;
        }

        if (!$content instanceof \Bolt\Legacy\Content || !property_exists($content, 'contenttype')) {
            return false;
        }

        // if the current requested page is for the same slug or singularslug.
        $ct = $content->contenttype;
        if ($routeParams['contenttypeslug'] === $ct['slug'] || $routeParams['contenttypeslug'] === $ct['singular_slug']) {
            // …and the slugs should match.
            return $routeParams['slug'] === $content['slug'];
        }

        return false;
    }
public function current ( $ content ) { /** @var Request $request */ $ request = $ this -> requestStack -> getCurrentRequest ( ) ; $ requestUri = $ request -> getRequestUri ( ) ; $ routeParams = $ request -> get ( '_route_params' ) ; // If passed a string, and it is in the route. if ( is_string ( $ content ) && in_array ( $ content , $ routeParams ) ) { return true ; } if ( is_array ( $ content ) ) { $ linkToCheck = isset ( $ content [ 'link' ] ) ? $ content [ 'link' ] : null ; } elseif ( $ content instanceof \ Bolt \ Legacy \ Content ) { $ linkToCheck = $ content -> link ( ) ; } else { $ linkToCheck = ( string ) $ content ; } // check against Request Uri if ( $ requestUri === $ linkToCheck ) { return true ; } // No contenttypeslug or slug -> not 'current' if ( empty ( $ routeParams [ 'contenttypeslug' ] ) || empty ( $ routeParams [ 'slug' ] ) ) { return false ; } // check against simple content.link if ( '/' . $ routeParams [ 'contenttypeslug' ] . '/' . $ routeParams [ 'slug' ] === $ linkToCheck ) { return true ; } if ( ! $ content instanceof \ Bolt \ Legacy \ Content || ! property_exists ( $ content , 'contenttype' ) ) { return false ; } // if the current requested page is for the same slug or singularslug. $ ct = $ content -> contenttype ; if ( $ routeParams [ 'contenttypeslug' ] === $ ct [ 'slug' ] || $ routeParams [ 'contenttypeslug' ] === $ ct [ 'singular_slug' ] ) { // …and the slugs should match. return $ routeParams [ 'slug' ] === $ content [ 'slug' ] ; } return false ; }
Returns true, if the given content is the current content.

If we're on page/foo, and content is that page, you can use
{% is page|current %}class='active'{% endif %}

@param \Bolt\Legacy\Content|array $content

@return bool true if the given content is on the curent page
Returns true if the given content is the current content .