Skip to content

docs: clarify dictionary method keys - #654

Open
janmarsino98 wants to merge 1 commit into
elapouya:masterfrom
janmarsino98:codex/docs-dict-method-keys
Open

docs: clarify dictionary method keys#654
janmarsino98 wants to merge 1 commit into
elapouya:masterfrom
janmarsino98:codex/docs-dict-method-keys

Conversation

@janmarsino98

Copy link
Copy Markdown

Summary

  • Document bracket notation for dictionary keys that collide with dictionary methods.
  • Clarify that autoescaping can prevent invalid XML but does not select the mapping key.

Why

{{ soil.pop }} resolves to the dictionary method rather than the pop context key. {{ soil['pop'] }} renders the intended value.

Fixes #496

Validation

  • git diff --check
  • Rendered a temporary DOCX with {{ soil['pop'] }} and confirmed that it reopens with the expected value.

@janmarsino98
janmarsino98 marked this pull request as ready for review July 14, 2026 13:01

@JackSpiece JackSpiece left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Verified this against the behavior reported in #496 with temporary DOCX templates. {{ soil.pop }} resolves to the dictionary method, autoescape=True renders that method representation as text rather than selecting the key, and {{ soil['pop'] }} renders 2 as intended. Without autoescaping, the method representation is interpreted as XML and the visible value is lost.

I also ran the exact project flake8 command, git diff --check, and a Sphinx dummy build with warnings treated as errors. All passed. This documents the workaround the owner requested and the placement is appropriate. Looks good.

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.

Corrupt document when passing a context with nested objects that have the word pop in the keys

2 participants