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

Containment operators #937

Closed
wisskid opened this issue Feb 24, 2024 · 5 comments · Fixed by #955
Closed

Containment operators #937

wisskid opened this issue Feb 24, 2024 · 5 comments · Fixed by #955
Milestone

Comments

@wisskid
Copy link
Contributor

wisskid commented Feb 24, 2024

Support for:

{if $i in [1, 2, 3]}...{/if}

and

{if $j not in [1, 2, 3]}...{/if}
@wisskid wisskid added this to the 5.1 milestone Feb 24, 2024
@wisskid
Copy link
Contributor Author

wisskid commented Feb 24, 2024

This could be extended to strings as well: {if 'im' in $name}..{/if}

@scottchiefbaker
Copy link

I like this idea a lot... Would it also work for:

{if $needle in $haystack_array}

@wisskid
Copy link
Contributor Author

wisskid commented Feb 25, 2024

@scottchiefbaker yes

@wisskid
Copy link
Contributor Author

wisskid commented Feb 25, 2024

It seems Smarty v5 also supports in_array as a function. (implemented as FunctionHandler.) This is undocumented.

@wisskid
Copy link
Contributor Author

wisskid commented Mar 18, 2024

Wow, this is funny. From the changelog in 2009: - added {if 'expression' is in 'array'} syntax
This is undocumented, and we do not have {if 'expression' is not in 'array'} yet.

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

Successfully merging a pull request may close this issue.

2 participants