Question

I am using trimpath library to draw dynamic page

I try to add expression to if clause

{for item in itemsObj}
 {if item_index % 4 == 3 && peopleObj.length != item_index + 1 }
     <div class="search-result-row" style="border-bottom:1px solid #dadada;">
 {/if}
{/for}

but the value "item_index + 1" not calculated as math expression and the result for this value is pinding string for example if item_index = 3 then the result for expression is = 31

could you please help me on this?

Was it helpful?

Solution

Disclaimer: I have no experience with this library.

According to the documentation:

The testExpr is any valid JavaScript expression, but no close-brace characters.

Which means you should be able to do this:

{if item_index % 4 == 3 && peopleObj.length != (parseInt(item_index, 10) + 1) }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top