Git Product home page Git Product logo

Comments (6)

freakdesign avatar freakdesign commented on July 28, 2024 2

Worth noting that cache=false will no longer work.

from shopify-code-snippets.

squatto avatar squatto commented on July 28, 2024 1

@mrpassiontea You can use the following as an alternative:

{{ 'tag' | link_to_add_tag: 'tag' | split: 'href="' | last | split: '"' | first | split: '?' | last | replace: '&', '&' }}

Bare in mind that this limits the param names you can use, I don't have a full list but I've found the following works:

  • q
  • key
  • id
  • collection
  • attributes
  • comment
  • email
  • note
  • tag
  • type
  • token

Hope this helps!

That's some impressive filter chaining πŸ˜‚ Given the lack of regex in liquid, that's a clever way to extract the URL from an anchor tag. Nice work!

from shopify-code-snippets.

tomblanchard avatar tomblanchard commented on July 28, 2024

@mrpassiontea You can use the following as an alternative:

{{ 'tag' | link_to_add_tag: 'tag' | split: 'href="' | last | split: '"' | first | split: '?' | last | replace: '&', '&' }}

Bare in mind that this limits the param names you can use, I don't have a full list but I've found the following works:

  • q
  • key
  • id
  • collection
  • attributes
  • comment
  • email
  • note
  • tag
  • type
  • token

Hope this helps!

from shopify-code-snippets.

hatprab avatar hatprab commented on July 28, 2024

@mrpassiontea You can use the following as an alternative:

{{ 'tag' | link_to_add_tag: 'tag' | split: 'href="' | last | split: '"' | first | split: '?' | last | replace: '&', '&' }}

Bare in mind that this limits the param names you can use, I don't have a full list but I've found the following works:

  • q
  • key
  • id
  • collection
  • attributes
  • comment
  • email
  • note
  • tag
  • type
  • token

Hope this helps!

That's some impressive filter chaining πŸ˜‚ Given the lack of regex in liquid, that's a clever way to extract the URL from an anchor tag. Nice work!

Here is the snippet using this method

{% capture pageUrl %}{{ "tag" | link_to_add_tag: "tag" | split: 'href="' | last | split: '"' | first | split: "?" | last | replace: "&", "&" }}{% endcapture %}
{%- assign pageQuerystring = pageUrl -%}
{%- assign parts = pageQuerystring | split:'&' -%}
{%- for part in parts -%}
 {%- assign keyAndValue = part | split:'=' -%}
 {{ keyAndValue[0] }}
 {{ keyAndValue[1] }}
{%- endfor -%}

from shopify-code-snippets.

lkoczorowski avatar lkoczorowski commented on July 28, 2024

Another take: snippets/fn.qs.liquid (has to be a one-liner)

{% capture pageUrl %}{{ "tag" | link_to_add_tag: "tag" | split: 'href="' | last | split: '"' | first | split: "?" | last | replace: "&", "&" }}{% endcapture %}{%- assign pageQuerystring = pageUrl -%}{%- assign parts = pageQuerystring | split:'&' -%}{%- for part in parts -%}{%- assign keyAndValue = part | split:'=' -%}{% if keyAndValue[0] == param %}{{ keyAndValue[1] | replace: "%2C", "," }}{% endif %}{%- endfor -%}

Usage:

{% capture qs_q %}{%- render 'fn.qs', param: "q" -%}{% endcapture %}
{% assign q_values = qs_q | split: "," %}
<!-- -{{q_values[0]}}- -{{q_values[1]}}- -{{q_values[2]}}- -{{q_values[3]}}- -->

from shopify-code-snippets.

mrpassiontea avatar mrpassiontea commented on July 28, 2024

Nowadays, I just use the JavaScript's urlsearchparams for anything relating to querystrings. I appreciate all your guys' help!

from shopify-code-snippets.

Related Issues (9)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.