Skip to content

Add support for dynamic setting of attributes from context based on #151 #152

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

maximbelyayev
Copy link

No description provided.

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds support for dynamically setting widget attributes from the rendering context based on #151.

  • Introduces a mechanism to merge a dynamically resolved dictionary into the attributes via the special key "attr_dict".
  • Refactors the handling of boolean and "type" attribute values during rendering.
Files not reviewed (1)
  • README.rst: Language not supported

if v:
if isinstance(v, bool):
bounded_field = set_attr(bounded_field, f"{k}")
if k == "type":
Copy link
Preview

Copilot AI Apr 25, 2025

Choose a reason for hiding this comment

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

The current conditional structure may result in duplicate attribute assignments for non-'type' keys with boolean values. Consider restructuring the conditionals using if-elif-else to ensure that each attribute is processed only once.

Suggested change
if k == "type":
elif k == "type":

Copilot uses AI. Check for mistakes.


.. code-block:: html+django

context_dict_var = {"type":"text", id="my_username_id", placeholder="Login"}
Copy link
Member

Choose a reason for hiding this comment

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

Is this correct? If this is a Python dict then shouldn't it be:

Suggested change
context_dict_var = {"type":"text", id="my_username_id", placeholder="Login"}
context_dict_var = {"type":"text", "id": "my_username_id", "placeholder: "Login"}

@aleksihakli
Copy link
Member

@maximbelyayev sorry for the delay in the review, would you happen to have the opportunity to look into the review notes?

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.

2 participants