liquid icon indicating copy to clipboard operation
liquid copied to clipboard

Unable to manipluate string, read-only?

Open lspoor opened this issue 4 years ago • 1 comments

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?

lspoor avatar Jan 06 '22 14:01 lspoor

Continuing to try and troubleshoot this, I tried doing the following:

assign data = replaced_data | append: '],[' | remove: '],['

This adds ],[ on the end and succesfully removes it, but it does not remove the ],[ in the rest of the string. Its almost like the replaced_data string is read only

lspoor avatar Jan 06 '22 16:01 lspoor