From 4c902500c987e96948b7295238cb817d28fba4e8 Mon Sep 17 00:00:00 2001 From: Gesina Schwalbe Date: Sat, 16 Jan 2021 23:47:05 +0100 Subject: [PATCH] unit values only displayed if given --- .../actor/partials/spells-overview.hbs | 31 ++++++++++++------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/src/templates/actor/partials/spells-overview.hbs b/src/templates/actor/partials/spells-overview.hbs index 5338955c..e7e865f7 100644 --- a/src/templates/actor/partials/spells-overview.hbs +++ b/src/templates/actor/partials/spells-overview.hbs @@ -2,25 +2,32 @@ {{!-- INLINE PARTIAL DEFINITIONS --}} {{!-- ======================================================================== --}} - -{{!-- -!-- Two templates for displaying values with unit. +{{!-- +!-- Base template to display a value with unit. !-- @param unitDatum: the object to display; must have a value and a unit attribute !-- @param localizationString -!-- @param config: the config object +!-- @param unitNames: mapping of allowed unitDatum.unit values to localized unit name +!-- @param unitAbbrs: mapping of allowed unitDatum.unit values to unit abbreviation +--}} +{{#*inline "unit"}} +
+ {{#if unitDatum.value }} + {{unitDatum.value}}{{lookup unitAbbrs unitDatum.unit}} + {{else}}-{{/if}} +
+{{/inline}} +{{!-- +!-- Two templates based on the "unit" template for displaying values with unit. +!-- Both accept a `config` object holding the unitNames and unitAbbr instead of +!-- directly handing over the latter two. --}} {{#*inline "temporalUnit"}} -
- {{unitDatum.value}}{{lookup config.temporalUnitsAbbr unitDatum.unit}} -
+{{> unit unitNames=config.temporalUnits unitAbbrs=config.temporalUnitsAbbr unitDatum=unitDatum localizationString=localizationString}} {{/inline}} {{#*inline "distanceUnit"}} -
- {{unitDatum.value}}{{lookup config.distanceUnitsAbbr unitDatum.unit}} -
+{{> unit unitNames=config.distanceUnits unitAbbrs=config.distanceUnitsAbbr unitDatum=unitDatum localizationString=localizationString}} {{/inline}}