# Nested loops inside Macros

**URL:** <https://community.hubspot.com/t/nested-loops-inside-macros/20746>\
**Category:** CMS Development\
**Created:** [May 11, 2020, 11:58am UTC](https://community.hubspot.com/t/nested-loops-inside-macros/20746 "2020-05-11T11:58:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![igcorreia](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/igcorreia/32/26131_2.png) [@igcorreia](https://community.hubspot.com/u/igcorreia)\
**Post date:** [May 11, 2020, 11:58am UTC](https://community.hubspot.com/t/nested-loops-inside-macros/20746/1 "2020-05-11T11:58:56Z")

</div>

Hi, I am trying to literally copy past this example inside a MACRO but it does not work:

> **[Accounts Dashboard | HubSpot](https://app.hubspot.com/myaccounts?next=developerdocs&redirect=%2Fcms%2Freference%2Fhubl%2Ffor-loops)**

```auto
{%- set macros = true %}

{%- macro loopexample() %}
{‌% set dict_var = {'name': 'Cool Product', 'price': '$20', 'size':'XL'} %} 
{‌% for key, val in dict_var.items() %}
 {‌{ key }}: {‌{ val }}

{‌% endfor %}
{%- endmacro %}

```

---

<div class="post-metadata">

**Author:** ![Kevin-C](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/kevin-c/32/34570_2.png) [@Kevin-C](https://community.hubspot.com/u/Kevin-C)\
**Post date:** [May 11, 2020, 4:55pm UTC](https://community.hubspot.com/t/nested-loops-inside-macros/20746/2 "2020-05-11T16:55:22Z")

</div>

Hey @igcorreia

So this code does work. See below:

```auto
{% set macros = true %}
{% macro demo() %}
{% set dict_var = {'name': 'Cool Product', 'price': '$20', 'size':'XL'} %} 
{% for key, val in dict_var.items() %}
 {{ key }}: {{ val }}<br>
{% endfor %}
{% endmacro %}

{{ demo() }}

```

Are you not calling the macro to display it? See:

`{{ demo() }}`
