# Use a variable as a module param value

**URL:** <https://community.hubspot.com/t/use-a-variable-as-a-module-param-value/82633>\
**Category:** CMS Development\
**Created:** [June 5, 2023, 9:29am UTC](https://community.hubspot.com/t/use-a-variable-as-a-module-param-value/82633 "2023-06-05T09:29:57Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![alvarofranz](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/alvarofranz/32/63428_2.png) [@alvarofranz](https://community.hubspot.com/u/alvarofranz)\
**Post date:** [June 5, 2023, 9:29am UTC](https://community.hubspot.com/t/use-a-variable-as-a-module-param-value/82633/1 "2023-06-05T09:29:57Z")

</div>

I am trying to pass this information to a custom module:

```lia-code-sample
{% set parent_items = [
{
"parent_item_link": {
"url": {
"href": "https://example.com"
},
"open_in_new_tab": true,
"rel": null
},
"parent_item_label": "Example 1"
},
{
"parent_item_link": {
"url": {
"href": "https://example.net"
},
"open_in_new_tab": false,
"rel": null
},
"parent_item_label": "Example 2"
},
{
"parent_item_link": {
"url": {
"href": "https://example.org"
},
"open_in_new_tab": true,
"rel": null
},
"parent_item_label": "Example 3"
}
] %}

{% module "hero_banner"
path='../modules/breadcrumb-hero',
label='Breadcrumb Hero',
parent_items=parent_items,
current_item_label='Current Page',
offset=0
%}

```

This doesn’t work, but if I provide the value directly **without setting it to a variable first** , it works perfectly:

```lia-code-sample
{% module "hero_banner"
path='../modules/breadcrumb-hero',
label='Breadcrumb Hero',
parent_items=[
 {
 "parent_item_link": {
 "url": {
 "href": "https://example.com"
 },
 "open_in_new_tab": true,
 "rel": null
 },
 "parent_item_label": "Example 1"
 },
 {
 "parent_item_link": {
 "url": {
 "href": "https://example.net"
 },
 "open_in_new_tab": false,
 "rel": null
 },
 "parent_item_label": "Example 2"
 },
 {
 "parent_item_link": {
 "url": {
 "href": "https://example.org"
 },
 "open_in_new_tab": true,
 "rel": null
 },
 "parent_item_label": "Example 3"
 }
 ],
current_item_label='Current Page',
offset=0
%}

```

How can I pass the value as a variable instead?

---

<div class="post-metadata">

**Author:** ![himanshurauthan](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/himanshurauthan/32/53076_2.png) [@himanshurauthan](https://community.hubspot.com/u/himanshurauthan)\
**Post date:** [June 5, 2023, 9:34am UTC](https://community.hubspot.com/t/use-a-variable-as-a-module-param-value/82633/2 "2023-06-05T09:34:01Z")

</div>

Hello @alvarofranz  
use the as keyword to assign the value to a variable and then pass that variable as a parameter.

```lia-code-sample
{% set parent_items = [
 {
 "parent_item_link": {
 "url": {
 "href": "https://example.com"
 },
 "open_in_new_tab": true,
 "rel": null
 },
 "parent_item_label": "Example 1"
 },
 {
 "parent_item_link": {
 "url": {
 "href": "https://example.net"
 },
 "open_in_new_tab": false,
 "rel": null
 },
 "parent_item_label": "Example 2"
 },
 {
 "parent_item_link": {
 "url": {
 "href": "https://example.org"
 },
 "open_in_new_tab": true,
 "rel": null
 },
 "parent_item_label": "Example 3"
 }
] %}

{% module "hero_banner"
 path='../modules/breadcrumb-hero',
 label='Breadcrumb Hero',
 parent_items=parent_items as parent_items_variable, # Assign the variable
 current_item_label='Current Page',
 offset=0
%}

```

as parent\_items\_variable, you assign the value of parent\_items to the variable parent\_items\_variable. pass parent\_items\_variable as the parent\_items parameter to the module.

---

<div class="post-metadata">

**Author:** ![alvarofranz](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/alvarofranz/32/63428_2.png) [@alvarofranz](https://community.hubspot.com/u/alvarofranz)\
**Post date:** [June 5, 2023, 9:44am UTC](https://community.hubspot.com/t/use-a-variable-as-a-module-param-value/82633/3 "2023-06-05T09:44:45Z")

</div>

Thanks, but this doesn’t work… now nothing shows at all. I’m also not really understanding what this is supposed to do.

---

<div class="post-metadata">

**Author:** ![Teun](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/teun/32/28739_2.png) [@Teun](https://community.hubspot.com/u/Teun)\
**Post date:** [June 5, 2023, 11:34am UTC](https://community.hubspot.com/t/use-a-variable-as-a-module-param-value/82633/4 "2023-06-05T11:34:37Z")

</div>

Hi @alvarofranz,

Could you try this:

```lia-code-sample
{% module "hero_banner"
path='../modules/breadcrumb-hero',
label='Breadcrumb Hero',
parent_items="{{parent_items}}",
current_item_label='Current Page',
offset=0
%}

```

---

<div class="post-metadata">

**Author:** ![alvarofranz](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/alvarofranz/32/63428_2.png) [@alvarofranz](https://community.hubspot.com/u/alvarofranz)\
**Post date:** [June 5, 2023, 12:39pm UTC](https://community.hubspot.com/t/use-a-variable-as-a-module-param-value/82633/5 "2023-06-05T12:39:10Z")

</div>

Thanks, this works as expected. I wonder why this is the way to do it, I thought {{ }} is used to print data, not to pass it as a param.

---

<div class="post-metadata">

**Author:** ![Teun](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/teun/32/28739_2.png) [@Teun](https://community.hubspot.com/u/Teun)\
**Post date:** [June 5, 2023, 12:40pm UTC](https://community.hubspot.com/t/use-a-variable-as-a-module-param-value/82633/6 "2023-06-05T12:40:14Z")

</div>

Great question, not one I can answer tho. I tried to pass variables in different ways, and this one worked, so I went with it 😅

---

<div class="post-metadata">

**Author:** ![alvarofranz](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/alvarofranz/32/63428_2.png) [@alvarofranz](https://community.hubspot.com/u/alvarofranz)\
**Post date:** [June 7, 2023, 12:01pm UTC](https://community.hubspot.com/t/use-a-variable-as-a-module-param-value/82633/7 "2023-06-07T12:01:42Z")

</div>

Note for future readers, it seems that the quotes are not necessary.

All of this works equally fine:

```lia-code-sample
{% module "whatever"
path='../modules/whatever',
give_me_some_value={{give_me_some_value}}
%}

{% module "whatever"
path='../modules/whatever',
give_me_some_value='{{give_me_some_value}}'
%}

{% module "whatever"
path='../modules/whatever',
give_me_some_value="{{give_me_some_value}}"
%}

```
