Printing out a variable, where part of the name of it is another variable?
Open
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 11.9k
- Forks
- 1.5k
- Avg merge
- 17h 55m
- Merged PRs (30d)
- 3
Description
I have a list of {% assign %} tags that go something like this:
{% assign blog_1_name = "blog 1" %}
{% assign blog_2_name = "blog 2" %}
{% assign blog_3_name = "blog 3" %}
{% assign blog_4_name = "blog 4" %}
And then I have another assign, called blog_count and set to 4. I would now like to loop over the blog_count and display the specific blog_X_name, where X is the current iteration. Tried something like this. Didn't work
{% for i in (1..postcount) %}
<div class="col-xs-12 col-md-6 col-md-offset-3 blogpost-link">
<h2>{{ blog_..i.._name }}</h2>
</div>
{%endfor%}
Can this be done?
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 asks whether Liquid can resolve a variable name assembled from the loop index, using the shown assign and for examples. Start by checking the existing variable lookup behavior and documentation; done means either confirming the supported syntax or documenting that this pattern is unavailable.
Written by the indexing model from the issue text.
Assessment
- Domain
- web-dev
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100