Skip to content

Commit f6ff5ec

Browse files
authored
Merge pull request #80 from twovectors/is_current_path_segments
Is current path segments
2 parents fa1d747 + 929b073 commit f6ff5ec

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ This component exposes a custom `path_for()` function to your Twig templates. Yo
6565
{% block body %}
6666
<h1>User List</h1>
6767
<ul>
68-
<li><a href="{{ path_for('profile', { 'name': 'josh' }) }}">Josh</a></li>
68+
<li><a href="{{ path_for('profile', { 'name': 'josh' }) }}" {% if is_current_path('profle', { 'name': 'josh' }) %}class="active"{% endif %}>Josh</a></li>
69+
<li><a href="{{ path_for('profile', { 'name': 'andrew' }) }}">Andrew</a></li>
6970
</ul>
7071
{% endblock %}
7172

src/TwigExtension.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ public function baseUrl()
5555
}
5656
}
5757

58-
public function isCurrentPath($name)
58+
public function isCurrentPath($name, $data = [])
5959
{
60-
return $this->router->pathFor($name) === $this->uri->getPath();
60+
return $this->router->pathFor($name, $data) === $this->uri->getPath();
6161
}
6262

6363
/**

0 commit comments

Comments
 (0)