-
Notifications
You must be signed in to change notification settings - Fork 100
Description
Description of the enhancement
Our Skosmos 3 Twig templates contain code like this for constructing the URL to the home page:
Skosmos/src/view/base-template.twig
Line 34 in 4368496
| <a id="skosmos-logo-top" href="{{ request.lang }}/{% if request.contentLang and request.contentLang != request.lang %}?clang={{ request.contentLang }}{% endif %}{% if request.queryParam('anylang') == 'on' %}{% if request.contentLang == request.lang %}?{% else %}&{% endif %}anylang=on{% endif %}"> |
(the same kind of snippet appears at least two more times further down in the same file)
This is a very cumbersome and fragile way of constructing the URL, which usully amounts to something like /en or /fi or /fi?clang=en . For other kinds of URLs, we already have defined a custom filter link_url for Twig. I think a similar filter, perhaps called vocab_url should be defined and used here, which would move the URL construction logic away from the Twig template and into the PHP backend code, which is better suited for this kind of conditional URL string manipulation.
Who are the users that would benefit from the enhancement and how?
Developers trying to keep sane
What new functionalities would the enhancement make possible?
Make the Twig template cleaner and easier to understand
Why is the enhancement important?
Refactoring early is good.