Skip to content

Commit

Permalink
Merge pull request #80 from twovectors/is_current_path_segments
Browse files Browse the repository at this point in the history
Is current path segments
  • Loading branch information
akrabat committed Sep 20, 2017
2 parents fa1d747 + 929b073 commit f6ff5ec
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ This component exposes a custom `path_for()` function to your Twig templates. Yo
{% block body %}
<h1>User List</h1>
<ul>
<li><a href="{{ path_for('profile', { 'name': 'josh' }) }}">Josh</a></li>
<li><a href="{{ path_for('profile', { 'name': 'josh' }) }}" {% if is_current_path('profle', { 'name': 'josh' }) %}class="active"{% endif %}>Josh</a></li>
<li><a href="{{ path_for('profile', { 'name': 'andrew' }) }}">Andrew</a></li>
</ul>
{% endblock %}

Expand Down
4 changes: 2 additions & 2 deletions src/TwigExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ public function baseUrl()
}
}

public function isCurrentPath($name)
public function isCurrentPath($name, $data = [])
{
return $this->router->pathFor($name) === $this->uri->getPath();
return $this->router->pathFor($name, $data) === $this->uri->getPath();
}

/**
Expand Down

0 comments on commit f6ff5ec

Please sign in to comment.