All files / owid-grapher/site DataValue.tsx

34.78% Statements 8/23
100% Branches 0/0
0% Functions 0/2
34.78% Lines 8/23

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 241x 1x 1x 1x 1x 1x             1x 1x                    
import React from "react"
import { DataValueProps } from "../clientUtils/owidTypes"
 
export const DATA_VALUE = "DataValue"
 
export const processTemplate = (props: DataValueProps) => {
    return props.template
        .replace("%value", props.formattedValue || props.value.toString())
        .replace("%year", props.year.toString() || "")
        .replace("%unit", props.unit || "")
        .replace("%entity", props.entityName || "")
}
 
export const DataValue = ({ label }: { label: string }) => {
    return (
        <span
            className="data-value"
            dangerouslySetInnerHTML={{
                __html: label,
            }}
        ></span>
    )
}