Shopify / Shopify/liquid

Unable to manipluate string, read-only?

Open
#1,503 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Ruby
Stars
11.9k
Forks
1.5k
Avg merge
17h 55m
Merged PRs (30d)
3

Description

So I have some data which is a string, I'm passing it into a section with the following method:

{%- liquid
    assign myData = 'data],[data],[data'

    capture header
        section 'header'
    endcapture

    assign header = header | replace: '%%DATA%%', myData
-%}

Then within sections/header.liquid I have the following

{% capture replaced_data %}
%%DATA%%
{% endcapture %}

{%- liquid
    assign data = replaced_data | split: '],['

    echo data[0]
-%}

Now based off that, you'd expect the first data to be printed out, but infact the following is printed out

data],[data],[data

For some reason I'm no longer able to do any manipulation with this data once its in the sections/header.liquid file. I've even tried doing a replace on the ],[ but it just doesn't take effect. Any ideas on this?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the behavior from the issue using the outer Liquid snippet and sections/header.liquid, focusing on the captured section output before the replace and split filters run. Compare the resulting value with the expected array element and determine whether section rendering preserves or changes the inserted string; done means the documented example behaves as expected or the limitation is clearly explained.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
web-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.