Skip to content
This repository has been archived by the owner on Jan 31, 2025. It is now read-only.
This repository has been archived by the owner on Jan 31, 2025. It is now read-only.

Component templates set variables in outer scope #4

Open
@lfdebrux

Description

Description of issue

The radios component template sets variables from an outer scope with the expectation that the value will be available later in the outer scope[2].

The Jinja template language has strict rules on the scope of variables; by default blocks cannot access variables set in outer scopes[1]. This is inline with the scoping behaviour of Python (as opposed to the scoping behaviour of JavaScript, which makes variables global by default).

The Jinja documentation is clear that setting variables in an outer scope will not work[3]. The suggested workaround is to use a namespace object.

Affected components

  • checkboxes
  • date-input
  • file-upload
  • radios
  • text-area

Possible workaround

Change the component templates to use a namespace object when setting a variable in an outer scope.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    discussionSomething to talk about

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions