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

Implement optional default for override_tag #125

Merged
merged 5 commits into from
Oct 28, 2020

Conversation

William-Blackie
Copy link
Contributor

Description

This PR provides away for a template tag to be provided a default value, across any template that is rendered. This default can be overridden in template specific context if desired so still allows for specific functionality when required.

Please include a summary of the changes and which issue this relates to (if applicable). Please list any dependencies that are required for this change.

Fixes # Request from feedback sheet.

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@bcdickinson bcdickinson changed the title Implement optional default for overide_tag Implement optional default for override_tag Sep 26, 2020
pattern_library/monkey_utils.py Outdated Show resolved Hide resolved
pattern_library/monkey_utils.py Outdated Show resolved Hide resolved
docs/README.md Outdated Show resolved Hide resolved
tests/templatetags/test_tags.py Outdated Show resolved Hide resolved
docs/README.md Outdated Show resolved Hide resolved
@William-Blackie William-Blackie force-pushed the feature/override_page_url_tag branch from ec2ab0d to 021300c Compare October 28, 2020 13:07
Copy link

@bcdickinson bcdickinson left a comment

Choose a reason for hiding this comment

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

UNSPECIFIED stuff looks good, just a couple of tweaks required for the docs and this will be ready to go.

docs/overview.md Outdated
@@ -134,6 +134,21 @@ The override process has two parts:
1. Override your template tag with a mock implementation
2. Define fake result for your tag in a `yaml` file


### Providing a default value for template tags
To provide a default for a template tag, you need to provide a keyword argument default when overriding your tag.

Choose a reason for hiding this comment

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

s/default/default_html/

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

docs/overview.md Outdated Show resolved Hide resolved
docs/overview.md Outdated Show resolved Hide resolved
docs/overview.md Outdated
This default is used for any tag that's not passed its own context, allowing specificity for those elements that need it while preventing the tag from breaking when it's not structural to the component.

#### limitation
Currently the default override is limited to direct references only i.e. {% a_tag_name page.url %} and not {% a_tag_name page.url as variable_name %}

Choose a reason for hiding this comment

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

I'm not sure about the wording here. What's actually not supported is modifying context, so it might be better to say something along the lines of "Only providing a default for the output of the tag is supporting, it's not possible to modify context like <example of simpletag as>".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fair point, thanks.

@William-Blackie William-Blackie merged commit 4dca246 into master Oct 28, 2020
@William-Blackie William-Blackie deleted the feature/override_page_url_tag branch October 28, 2020 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

2 participants