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 url_add_param and url_remove_param filters #1642

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

andershagbard
Copy link
Contributor

This PR adds url_add_param and url_remove_param filters.

Usage:

{{ 'https://shopify.com' | url_add_param: 'foo', 'bar' }} => https://shopify.com?foo=bar
{{ 'https://shopify.com?foo=bar' | url_remove_param: 'foo' }} => https://shopify.com?

Specific use case:
When using the same snippet for product cards in product recommendations and collections, and you want to add a param to the product.url. In product recommendations, the product.url already has params, and in collections, it does not.

These filters makes it very easy to add these params, without worrying about existing.

Caveats
You can't override existing params. It will just append the param, and make it an "array". This is intended.

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.

1 participant