Comments (7)
If someone have this bug, try to use CamelCase with operators
{% assign testArray = "first/second/third/fourth" | Split: '/' %}
First element: {{testArray | First}}
Last element: {{testArray | Last}}
Size: {{testArray | Size}}
It helped me
from dotliquid.
@thinkOfaNumber this is expected behavior
- split and Split are not synonyms. Depending on the selected naming convention, one or the other will work. In your case, the
CSharpNamingConvention
seems in use. - Using an unknown filter is ignored and value remains unchanged. SO: split results in string object while Split has a string array.
- string are char array in c# so for loops on the former iterate character by character while the string array works as you want.
from dotliquid.
Thanks for the heads-up - this filter was added to Liquid fairly recently, and I've ported it to DotLiquid. Fixed by de1c318.
from dotliquid.
Thanks for adding it. However, I don't think this is working properly for all cases. For example, suppose I have a string that I would want to split and then use part of it. It seems that I cannot assign it to an array, as I've tried:
{% capture testArray %}{{ "first/second/third/fourth" | split:"/" }}{% endcapture %}
First element: {{testArray | first}}
Last element: {{testArray | last}}
{% assign testArray1 = "first/second/third/fourth" | split: '/' %}
First element: {{testArray1 | first}}
Last element: {{testArray1 | last}}
The only thing I can do is get the first or last element, like this, but not the other ones:
{% capture firstValue %}{{ "first/second/third/fourth" | split:"/" | first}}{% endcapture %}
{{firstValue}}
{% capture lastValue %}{{ "first/second/third/fourth" | split:"/" | last}}{% endcapture %}
{{lastValue}}
from dotliquid.
Do you mean you want to access an array element at an arbitrary index? If you could include the code you hope to be able to write, that would help.
Just to be clear, this works fine for me - I'm not sure if you were saying that it's not working:
{% assign testArray1 = "first/second/third/fourth" | split: '/' %}
First element: {{testArray1 | first}}
Last element: {{testArray1 | last}}
from dotliquid.
Here is the one of the example
"franchises":[
{% assign beatles = "12,34" | split: "," %}
{% for member in beatles %}
{
number" : {{ member }}
},
{% endfor %}
]
here the split is not working and i'm getting output like
"franchises": [
{
"number": "1"
},
{
"number": "2"
},
{
"number": ","
},
{
"number": "3"
},
{
"number": "4"
}
]
from dotliquid.
It's 2023, is this an undocumented feature?
{%- assign emailLowerSplit = "[email protected]" | split: '@' -%}
{%- assign emailUpperSplit = "[email protected]" | Split: '@' -%}
{% for part in emailLowerSplit -%}
{{ part }}
{% endfor %}
{% for part in emailUpperSplit -%}
{{ part }}
{% endfor %}
produces
m
e
@
h
e
r
e
.
c
o
m
me
here.com
from dotliquid.
Related Issues (20)
- Template Render Performance Issues HOT 2
- Allow adding filters by value (eg. lambda method). HOT 1
- Enhancement: Ability to utilize the Legacy Regex-based Replace filters
- Website http://dotliquidmarkup.org/ doesn't load HOT 1
- Map Filter Unnamed Property Incorrect Result HOT 1
- Blank Condition Test
- CSharpNamingConvention causes bugs HOT 1
- DotLiquid string array contains returns true for substring HOT 1
- Slice not working as expected HOT 1
- How to get the list of variables used in a liquid template? HOT 3
- IndexOutOfRangeException HOT 3
- Accessing a 2nd level nested array element in dotliquid Json to Json transform step throws undefined, undefined error HOT 1
- Inconsistent rendering of arrays when done directly vs in a Sort filter HOT 8
- Dotliquid not parsing object array in liquid template
- Unsupported type DateOnly in .Net 7.0+
- Dotliquid Ignored CultureInfo settings if CultureInfo.CurrentCulture is InvariantCulture HOT 1
- Empty string / null check not working HOT 10
- Concurrent Access Error in RegisterSafeType Method HOT 3
- Line breaks in literal strings fail to parse HOT 1
- base64_encode / base64_decode filters HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dotliquid.