# Conditional logic through HTML code

**URL:** <https://community.hubspot.com/t/conditional-logic-through-html-code/135773>\
**Category:** CMS Development\
**Tags:** design-manager\
**Created:** [July 7, 2025, 12:26pm UTC](https://community.hubspot.com/t/conditional-logic-through-html-code/135773 "2025-07-07T12:26:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ViniBernardo](https://avatars.discourse-cdn.com/v4/letter/v/a6a055/32.png) [@ViniBernardo](https://community.hubspot.com/u/ViniBernardo)\
**Post date:** [July 7, 2025, 12:26pm UTC](https://community.hubspot.com/t/conditional-logic-through-html-code/135773/1 "2025-07-07T12:26:50Z")

</div>

Hi everyone, I have a question related to a HubSpot custom quote template.

Is it possible to create a type of conditional logic via Hub HTML? More specifically, I wanted to create a table that can only appear if a specific line item type is selected.

I tried to create something using:

“{% set itens\_horas = [] %}  
{% for item in line\_items %}  
{% set nome\_normalizado = item.name|upper|trim %}  
{% if “HORA” in nome\_normalizado %}  
{% set itens\_horas = itens\_horas + [item] %}  
{% endif %}  
{% endfor %}  
{% if itens\_horas|length \> 0 %}”

but despite that, it ended up not working. Is there a specific way?

 ![1173566_1_Captura de tela 2025-07-07 092612.jpg](https://d2qpr2jzcazej7.cloudfront.net/original/3X/7/c/7c8603db5b25bb156fe53e89df12223587075e38.jpeg)

---

<div class="post-metadata">

**Author:** ![MichaelMa](https://avatars.discourse-cdn.com/v4/letter/m/b5ac83/32.png) [@MichaelMa](https://community.hubspot.com/u/MichaelMa)\
**Post date:** [July 7, 2025, 12:45pm UTC](https://community.hubspot.com/t/conditional-logic-through-html-code/135773/2 "2025-07-07T12:45:52Z")

</div>

The primary issue you have is that you cannot SET variables in a FOR loop that was created outside it’s block. This is why it’s not working.

You can cheat it, however, by doing using the DO command to update an array or object:

So where you have the line:

`{% set itens_horas = itens_horas + [item] %}`

You can use APPEND to push the name of the item into the array.

`{% do itens_horas.append(nome_normalizado) %}`

What’s pushed into the array doesn’t seem to matter (eg, you can simply push in true if you wanted) as you look to be just checking the array length later.
