# Creating a dynamic capture

**URL:** <https://community.silverfin.com/t/creating-a-dynamic-capture/1559>\
**Category:** Templates\
**Created:** [September 4, 2019, 12:03pm UTC](https://community.silverfin.com/t/creating-a-dynamic-capture/1559 "2019-09-04T12:03:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ronald\_groot\_RSF](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.silverfin.com/ronald_groot_rsf/32/1019_2.png) [@ronald\_groot\_RSF](https://community.silverfin.com/u/ronald_groot_RSF)\
**Post date:** [September 4, 2019, 12:03pm UTC](https://community.silverfin.com/t/creating-a-dynamic-capture/1559/1 "2019-09-04T12:03:26Z")

</div>

I need some help with the code below. Within a template I’m creating multiple tables with the same design. So, what I’d like to do is create a number of captures dynamically, so I call on them later on in my code. What I’m going for is this:

```auto
{% assign categories = "name1;value1|name2;value2" | split:"|" %}

{% for category in categories %}

  {% assign parts = category | split:";" %}
  
{% capture table_name %}table_{{ parts[0] }}{% endcapture %}
{% capture result_value %}{{ parts[1] }}{% endcapture %}

{% capture [table_name] %}
{{ result_value }}
{% endcapture %}
{% endfor %}

{{ table_name1 }}

```

But this gives me an no value for {{table\_name1}}, where I would suspect to see value1.

Am I doing something wrong?

---

<div class="post-metadata">

**Author:** ![Jelena\_Sutova](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.silverfin.com/jelena_sutova/32/599_2.png) [@Jelena\_Sutova](https://community.silverfin.com/u/Jelena_Sutova)\
**Post date:** [September 4, 2019, 12:33pm UTC](https://community.silverfin.com/t/creating-a-dynamic-capture/1559/2 "2019-09-04T12:33:38Z")

</div>

Hi

When you are capturing a name of the variable, the variable cannot be between brackets. Please use assign for variables in brackets:

```auto
{% assign categories = "name1;value1|name2;value2" | split:"|" %}

{% for category in categories %}

  {% assign parts = category | split:";" %}

{% capture table_name %}table_{{ parts[0] }}{% endcapture %}
{% capture result_value %}{{ parts[1] }}{% endcapture %}

{% capture temp_table_name_value %}{{ result_value }}{% endcapture %}
{% assign [table_name] = temp_table_name_value %}

{% endfor %}

{{ table_name1 }}

```

Please let me know if this works for you.  
Thanks

---

<div class="post-metadata">

**Author:** ![ronald\_groot\_RSF](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.silverfin.com/ronald_groot_rsf/32/1019_2.png) [@ronald\_groot\_RSF](https://community.silverfin.com/u/ronald_groot_RSF)\
**Post date:** [September 4, 2019, 12:55pm UTC](https://community.silverfin.com/t/creating-a-dynamic-capture/1559/3 "2019-09-04T12:55:06Z")

</div>

Yeah that makes perfect sense, thanks so much!

---

<div class="post-metadata">

**Author:** ![sven](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.silverfin.com/sven/32/1495_2.png) [@sven](https://community.silverfin.com/u/sven)\
**Post date:** [September 4, 2019, 1:08pm UTC](https://community.silverfin.com/t/creating-a-dynamic-capture/1559/4 "2019-09-04T13:08:00Z")

</div>


