Skip to content
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

Allow using 'data' rather than 'data from code' for al_nav_sections #844

Merged
merged 1 commit into from
Apr 26, 2024

Conversation

nonprofittechy
Copy link
Member

@nonprofittechy nonprofittechy commented Apr 25, 2024

Currently, when you use the al_nav_sections method to declaratively define navigation, you need the longer and more verbose data from code because the hidden dictionary key is evaluated as a str.

For example:

---
reconsider: True
variable name: al_nav_sections
data from code:
  - section_intro: |
      "Introduction"
  - section_about_you: |
      "About you"
  - section_about_spouse: |
      "About your spouse"
    hidden: not is_married

works but

reconsider: True
variable name: al_nav_sections
variable name: al_nav_sections
data:
  - section_intro: Introduction
  - section_about_you: About you
  - section_about_spouse: About your spouse
    hidden: ${ not showifdef("is_married") }

does not.

Type coercion is safe here because structurally, hidden is only meant to ever be a boolean value. it's only acted on when the value is exactly True.

Copy link

@samglover samglover left a comment

Choose a reason for hiding this comment

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

Makes sense and LGTM!

@nonprofittechy nonprofittechy merged commit 9347434 into main Apr 26, 2024
5 checks passed
@nonprofittechy nonprofittechy deleted the allow-string-hidden-for-nav branch April 26, 2024 20:17
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