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 main thing about this merge request is that it adds parsing capability for arbitrary Twig tags. This capability is activated through an option
allowUnknownTags
.Background: If we only want to parse a Twig file, without executing it, we don't need custom parsers for all kinds of Twig tags. In this case, Melody can generate AST nodes of type
GenericTwigTag
for Twig tags it does not know.This is good enough for "lone" Twig tags like
{% exit 404 %}
. However, sometimes, pairs or even groups of Twig tags belong together. Example:Here,
{% nav %}
and{% endnav %}
, as well as{% ifchildren %}
and{% endifchildren %}
belong together.In order to have such tags adequately represented in the AST, they have to be made known to the Melody parser beforehand. The new option
multiTags
is used for that:multiTags
is an object whose keys are the tag names of the first in a sequence of tags (here,nav
andifchildren
), and whose values are arrays containing the other tag names that can occur in the sequence. It's important that the concluding tag name comes last in this array. Other than that, the order does not matter.