This is probably something small I am missing. I have a list and each item has a category. The goal for the code is to just output a row with the category information after it changes but I just can’t seem to get it to work. The if statement is always true even if the values are identical. I just want that row to print when the category name changes. What am I missing?
Thanks but in your example you aren’t reassigning the catorderItemCategoryString to cat when it is found so that the header only displays when the category changes. Just a simple thing regarding logic that I can’t seem to get to work here. Here is some code that reproduces it:
{{ var orderItems= [{orderItemCategoryString:“A”},{orderItemCategoryString:“A”},{orderItemCategoryString:“B”},{orderItemCategoryString:“B”},{orderItemCategoryString:“C”}] }}
{{“cat no exist” |> to=>cat}}
{{#each orderItems}}
{{#if it.orderItemCategoryString != cat}}
Table Header for my example should only be one per category - {{cat}}
{{ it.orderItemCategoryString |> to=> cat}}
{{/if}
{{/each}}
The output should be:
Table Header for my example should only be one per category - A
Table Header for my example should only be one per category - B
Table Header for my example should only be one per category - C