Skip to content

Feature Request: Logical operators for handlebar helpers #343

@Jabbl

Description

@Jabbl

Jellyfin Webhooks supports custom helper methods like {{#if_equals <a> <b>}} and {{#if_exists <a>}}.
These can be used in the template to exclude certain values if the notification has or lacks some properties.

What I'm missing is a logical && and/or || operator that can be used to exclude entire sections based on multiple conditions.

Example:
I have this template which only makes sense for events caused by playback (Start, End, Progress):

  "Playback":
  {
    "PlaybackPosition": "{{PlaybackPosition}}",
    "TotalRuntime": "{{RunTime}}"
  }

To get this data to show for all of these events, but none other, I have these options:

  1. Just let the section always show up for all webhooks
  2. Add the following:
{{#if_equals NotificationType 'PlaybackStart'}}
  "Playback":
  {
    "PlaybackPosition": "{{PlaybackPosition}}",
    "TotalRuntime": "{{RunTime}}"
  }
{{/if_equals}}
{{#if_equals NotificationType 'PlaybackEnd'}}
  "Playback":
  {
    "PlaybackPosition": "{{PlaybackPosition}}",
    "TotalRuntime": "{{RunTime}}"
  }
{{/if_equals}}
{{#if_equals NotificationType 'PlaybackProgress'}}
  "Playback":
  {
    "PlaybackPosition": "{{PlaybackPosition}}",
    "TotalRuntime": "{{RunTime}}"
  }
{{/if_equals}}

For purposes like this, it would be preferable if there were some kind of logical operators available, e.g.:

{{#if_any NotificationType 'PlaybackStart' 'PlaybackEnd' 'PlaybackProgress'}}
  "Playback":
  {
    "PlaybackPosition": "{{PlaybackPosition}}",
    "TotalRuntime": "{{RunTime}}"
  }
{{/if_equals}}

Or similar.

Now, I'm quite familiar with .NET, but have never squabbled with Handlebars.NET, so I don't know how hard this would be, or if it would be easier to implement logical OR/AND operators instead ({{#if_equals NotificationType 'ProgressStart' || 'ProgressEnd' }}, but a feature like this would make the templating much more compact in certain scenarios.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions