Allow includes in feature templates #7020
Merged
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.
Fix for #6113.
The issue was that
[feature]
tags are only processed within a[resultset]
tag. If included templates don't contain the[resultset]
tag the template content is left as a raw string.When processing
[resultset]
the code searches through the file for the closing[resultset]
tag and gets the content inbetween, without processing[include]
tags.This pull request adds a call to
processIncludeTag
withinprocessResultSetTag
which resolves the issue.In addition several typos were corrected (as there was quite a bit of time debugging this file to find the issue). Sorry this makes the actual code changes harder to review.
In the end the only required code changes were adding the following, and moving
processIncludeTag
higher in the file to ensure it was checked:There was also a couple of (existing) memory leaks in the case where templates were missing that have been fixed. These were highlighted by the Address Sanitizer CI when new tests were added.
This pull request includes test files to check the issues reported in #6113 - including a JSON example of stripping the last comma when using includes.
One minor (again I believe existing) issue, is that the templates write to a stream, so if errors are encountered after output has been sent then any template text has already been written.
This leads to slightly messed up error responses - such as in the test result template_test005.html
As this error only occurs when templates are missing it will probably only be seen by the developers of a system rather than users.