fix: re-render answers file path when producing render context #1840
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.
I've fixed a bug related to rendering a template answers file name/path in combination with
_message_before_copy
.The reason for this bug is as follows: When
_message_before_copy
is set, Copier renders this message before starting the questionnaire, and thus at this point the render context does not include any answers of questions, so rendering the templated_answers_file
value leads to an incorrect result – but there's likely no practical reason to render the answers file in the pre-copy message. But rendering the pre-copy message requires the render context which contains the rendered answers file and prior to this PR the rendered answers file value was cached, hence the incorrect value was cached when the first render context was produced for rendering the pre-copy message.This PR solves the problem by simply re-rendering the answers file path every time a render context is produced.
By the way, this bug would have been caught with less confusion if Copier had supported configuring Jinja with
StrictUndefined
. 🤓Fixes #1825.