Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The template resolver is supposed to determine the handler, format, and variant from the path in extract_handler_and_format_and_variant.
Previously this behaviour was close but didn't exactly match the behaviour of finding templates, and in some cases (particularly with handlers or formats missing) would return incorrect results. I've added previously failing test for where the variant was misdetected.
This commit introduces Resolver::PathParser, a class which should be able to accurately from any path inside a view directory be able to tell us exactly the prefix, partial, variant, locale, format, variant, and handler of that template.
This works by building a building a regexp from the known handlers and file types. This requires that any resolvers have their cache cleared when new handlers or types are registered (this was already somewhat the requirement, since resolver lookups are cached, but this makes it necessary in more situations).
Keen readers will note that there's now two different regexes being made in this file 😓. One for finding files and this new one. In a follow up PR #39362 I intend to replace the find logic to instead use this regex, which will require some extra filtering. This will be possible because we have deprecated
.
s from being part of the action name, making the template names unambiguously refer to these properties.This could also allow us in the future to offer
did_you_mean
style suggestions on missing templates (I really love these changes we've been seeing), or even parsing the entireapp/views
directory at boot (or on the firstrender
call) and warning the user about any template's extensions we don't understand.Thanks for reading ❤️