statgen / locuszoom

A Javascript/d3 embeddable plugin for interactively visualizing statistical genetic data from customizable sources.
https://statgen.github.io/locuszoom/
MIT License
156 stars 29 forks source link

Allow template string syntax to support "else" branch on if statements #215

Closed abought closed 3 years ago

abought commented 4 years ago

Sometimes in tooltips, we want to control what is rendered based on existing data. Eg, a tooltip might contain an action button that says "show label", and once clicked the text should change to "hide label".

Currently our template syntax supports only if statements ("if a value is present at all"). An else block would be helpful for this use case.

Currently the if statement only checks if a value is present. Some additional development would be necessary to assess whether the current grammar allows smarter conditionals: