NovuN
Novu2y ago
Mei

Discussion: Handlebars helper for digest/non digest

We allow our subscribers to decide whether or not they want digests enabled by putting a filter based on subscriber data on our digest steps.

The problem is that taking into account all the states in which a digest with a filter could leave the Handlebars template variables (no step.events, step.events but step.events.length = 1, and step.events.length > 1) results in a very janky template like the below

{{#unless step.digest}}
  nondigest stuff with {{payload_property}}
{{else}}
  {{#equals step.total_count 1}}
    nondigest stuff with {{payload_property}} <- duplicated!!
  {{#else}}
      digest stuff with {{#each step.events}}{{payload_property}}{{/each}}
  {{/equals}}
{{/unless}}


I think Novu should provide a Handlebars helper to abstract away the two required unless+equals branches so that the user does not need to duplicate the part of the template intended for non-digest/digests with a single event. I’m willing to write a PR to implement such a helper but thought I should discuss it here before opening an issue
Was this page helpful?