unit values only displayed if given
This commit is contained in:
parent
bbf9c35a6b
commit
4c902500c9
1 changed files with 19 additions and 12 deletions
|
@ -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"}}
|
||||
<div class="unit-data-pair item-num-val"
|
||||
title="{{localize localizationString}} [{{lookup unitNames unitDatum.unit}}]" >
|
||||
{{#if unitDatum.value }}
|
||||
{{unitDatum.value}}{{lookup unitAbbrs unitDatum.unit}}
|
||||
{{else}}-{{/if}}
|
||||
</div>
|
||||
{{/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"}}
|
||||
<div class="unit-data-pair item-num-val"
|
||||
title="{{localize localizationString}} [{{lookup config.temporalUnits unitDatum.unit}}]" >
|
||||
{{unitDatum.value}}{{lookup config.temporalUnitsAbbr unitDatum.unit}}
|
||||
</div>
|
||||
{{> unit unitNames=config.temporalUnits unitAbbrs=config.temporalUnitsAbbr unitDatum=unitDatum localizationString=localizationString}}
|
||||
{{/inline}}
|
||||
|
||||
{{#*inline "distanceUnit"}}
|
||||
<div class="unit-data-pair item-num-val"
|
||||
title="{{localize localizationString}} [{{lookup config.distanceUnits unitDatum.unit}}]" >
|
||||
{{unitDatum.value}}{{lookup config.distanceUnitsAbbr unitDatum.unit}}
|
||||
</div>
|
||||
{{> unit unitNames=config.distanceUnits unitAbbrs=config.distanceUnitsAbbr unitDatum=unitDatum localizationString=localizationString}}
|
||||
{{/inline}}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue