Map items at specific index
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 11.9k
- Forks
- 1.5k
- Avg merge
- 17h 55m
- Merged PRs (30d)
- 3
Description
If I have an array of arrays, or a mapping, I'm looking for a version of map that will get me the items at specific index for the subarrays, or all the items of a key->item mapping.
For example, if I have an arr.yml file that looks like this:
key1: "item1"
key2: "item2"
or
- ['key1', "item1"]
- ['key2', "item2"]
I don't see any way to get just [ "item1", "item2" ].
Something like the following would be very useful:
{{ arr | index: 1 }} or {{ arr | map: '[1]' }}
I can't find any current way of doing this, except to use Jekyll support for push, i.e.:
{% assign tmp = "" | split: "," %}
{% for p in arr %}
{% assign tmp = tmp | push: p[1] %}
{% endfor %}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue names no files or tests. Start by tracing the existing map behavior and the Jekyll push workaround, then compare the mapping and nested-array examples. Done means the requested filter behavior is defined for both forms and covered by tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- jekyll, yaml
- Domain
- web-dev
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100