APIs & Integrations

andre9000
Contributeur

Hubl: How to do a normal loop (print something n times)

Résolue

Hi,

I want to do loop for 12 times:

{% set cols = 12 %}
{% for i in cols %}
// do something with i
{% endfor %}

However, this doesn't work, since cols is not an object or array. I don't want it to be, I want a plain loop for 12 times. How can I achieve this within HubL?

Thanks in advance :slight_smile:

0 Votes
1 Solution acceptée
IsaacTakushi
Solution
HubSpot Employee
HubSpot Employee

Hubl: How to do a normal loop (print something n times)

Résolue

Hi @andreks,

It doesn't look like HubL has a method for this. All examples I've found use objects or arrays. Here's the simplest code I've come up with:

{% set iterations = range(1, 13) %}
{% for i in iterations %}
{{ i }}
{% endfor %}

Isaac Takushi

Associate Certification Manager

Voir la solution dans l'envoi d'origine

1 Réponse
IsaacTakushi
Solution
HubSpot Employee
HubSpot Employee

Hubl: How to do a normal loop (print something n times)

Résolue

Hi @andreks,

It doesn't look like HubL has a method for this. All examples I've found use objects or arrays. Here's the simplest code I've come up with:

{% set iterations = range(1, 13) %}
{% for i in iterations %}
{{ i }}
{% endfor %}

Isaac Takushi

Associate Certification Manager