Skip to content

Add extra context to template rendering#88

Merged
mgax merged 5 commits into
mainfrom
feature/extra-template-context
Aug 14, 2025
Merged

Add extra context to template rendering#88
mgax merged 5 commits into
mainfrom
feature/extra-template-context

Conversation

@mgax
Copy link
Copy Markdown
Member

@mgax mgax commented Aug 6, 2025

Fixes #80.

Comment thread wagtail_newsletter/models.py Outdated
def get_newsletter_html(self, extra_context=None) -> SafeString:
context = self.get_newsletter_context()
if extra_context:
context = copy(context)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: why copy the context dict? It seems like an unnecessary step given that it isn't reused. If observing immutability of the dict is important for some reason, you could use the dict union operator and skip the import.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a bit of paranoia in case people do something silly.

I thought being explicit was better, but now I like the ** approach better. Changed in 0747582. Thanks!

@mgax mgax merged commit b501f40 into main Aug 14, 2025
7 checks passed
@mgax mgax deleted the feature/extra-template-context branch August 14, 2025 08:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

get_newsletter_html should accept extra context

2 participants