2
{{#each myArray}}
<div class="product-default-single-item product-color--golden" data-aos="fade-up" data-aos-delay="{{@index * 200}}">
</div>
{{/each}}

This is my code . I want a dynamic delay to all contents which added dynamically. For example if i add another product in mongodb then i want to multiply his index to 200. @index is working fine . I'm getting @index but Multiply() or Add(+) is not working. when i add multiply() or add (+). It give me error.

  • Perhaps you will need to create a custom helper. See: https://handlebarsjs.com/guide/#custom-helpers – 76484 Jul 21 '22 at 10:41

1 Answers1

2

Here is the answer from my point of view. First you need to create a custom helper here is the code example

hbs.registerHelper("multiple",function(index,value){
    return index * value;
}


{{#each myArray}}
    <div class="product-default-single-item product-color--golden" data-aos="fade-up" data-aos-delay="{{#multiple @index 200}}{{/multiple}}">
    </div>
{{/each}}
//Let the myArray length is 2
// The output will be 0 and 200