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

fix: loop over forward slashes for relative dir, replace after urlencode #64

Open
wants to merge 1 commit into
base: v5.5.x
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion src/Resources/themes/default/layout/layout.twig
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
<select class="form-control" id="version-switcher" name="version">
{% for version in project.versions %}
<option
value="{{ path('../' ~ version|url_encode ~ '/index.html') }}"
value="{% for i in project.version|split('/') %}../{% endfor %}{{ path(version|url_encode|replace({ '%2F': '/' }) ~ '/index.html') }}"
Copy link

@GuySartorelli GuySartorelli Mar 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd recommend making a new template function in PHP-land.
That means:

  1. You can unit test the function
  2. Templates are easier to read - these templates are already pretty complicated
  3. If this same thing needs to happen elsewhere, the same function can be reused
  4. It's easier to make readable functional code in PHP than templates (imo)

data-version="{{ version }}" {{ version == project.version ? 'selected' : ''}}>{{ version.longname }}</option>
{% endfor %}
</select>
Expand Down