CMS Development

bluejaye
Member

How to change a variable value?

Hi Guys

 

If I defined a varaible like {{% set age = 18%}},  how can I change age's value in a loop or macro or in  a if statement?

 

Demo 1:

{% set age = 8 %}
{%if statement%}
{% age = 10 %} //here has syntax error
{% end if%} 

 

Demo 2

{% set age = 8 %}
{%if statement%}
{% set age = 10 %} //if I use set, it just create another variable, it won't update outside age to 10
{% end if%}

 

Cheers

1 Reply 1
TRooInbound
Key Advisor

How to change a variable value?

Hi @bluejaye,

 

Any variables in HubSpot hubl are limited to that scope, you can only use in that scope only. you can use Demo2 in your code to avoid any misunderstanding related to variables, here is the link for developer forum discussion for more details.

 

Hope it works for you

 

Did our post help answer your query? Help the Community by marking it as a solution.

 

Team TRooInbound | hello@trooinbound.com | https://www.trooinbound.com

0 Upvotes