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

Add a new test "search" #2041

Closed
DCAuto opened this issue Oct 23, 2024 · 1 comment
Closed

Add a new test "search" #2041

DCAuto opened this issue Oct 23, 2024 · 1 comment

Comments

@DCAuto
Copy link

DCAuto commented Oct 23, 2024

This test will be the inverse of "in". Primary use will be for the selectattr filter to search for substrings in a list of dictionaries.

Example:
Given the following list of dictionaries:

test_list = [
    {"name": "John"},
    {"name": "Jose"},
    {"name": "Beth"},
    {"name": "Jake"},
]

Within the template, extract list items that have the sub-string "Jo" in the "name" key:

{{ test_list | selectattr("name", "search", "Jo") | list }}
@davidism
Copy link
Member

Duplicate of #1766

@davidism davidism marked this as a duplicate of #1766 Oct 23, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 8, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants