Currently, when adding a partial template into an HTML file, we cannot pass any variable/props to it, making it quite limited when it comes to reusing code in our projects.
Let me give you an example to better understand what I mean.
Imagine you have a partial template that includes a navigation element. This navigation element is shared accross pages but some items are highlighted according to what page you are visiting.
Imagine it looks like this:
Item 1 | Item 2 | Item 3
When you are visiting different pages, the navigation item should work as follows:
Page 1 --> Item 1 | Item 2 | Item 3
Page 2 --> Item 1 | Item 2 | Item 3
Page 3 --> Item 1 | Item 2 | Item 3
As you can see in the previous example, the items inside the navigation are "highlighted" according to the page we visit.
Now imagine we have different templates for each page but the navigation element is the same, so it makes sense to have it in a partial template and include it in each template instead of coding it three times.
The problem comes when I want this partial template to behave differently according to the page I'm visiting.
At this moment we can achieve this by, for exampe, checking the URL and adding some logic based on that, but it's not really scalable.
What would be awesome (and in my opinion a game changer when it comes to developing pages in Hubspot CMS) is to be able to pass variables (like props in React) to the partial templates.
In the previous example, would be nice to do something like this:
{% include "./components/nav.html" props='item1' %}
<div class="{% if props == 'item1' %} active {% endif %}"> </div>