TextOnlyPhrase

TextOnlyPhrase brukes for gjenbrukbare tekstfragmenter som kan inneholde formattering. Den er nyttig for standardiserte tekstbiter som skal brukes på flere steder. F.eks i tabeller eller liste-elementer.

Definere en TextOnlyPhrase

data class GarantipensjonSatsTypeText(
    val satsType: Expression<GarantipensjonSatsType>,
) : TextOnlyPhrase<LangBokmalNynorskEnglish>() {
    // TextOnlyScope gir tilgang til text() med FontType-parameter
    override fun TextOnlyScope<LangBokmalNynorskEnglish, Unit>.template() {
        val hoysats = satsType.equalTo(GarantipensjonSatsType.HOY)
        val ordinaer = satsType.equalTo(GarantipensjonSatsType.ORDINAER)
        showIf(hoysats) {
            text(
                bokmal { + "høy sats" },
                nynorsk { + "høg sats" },
                english { + "high rate" },
                FontType.BOLD
            )
        }.orShowIf(ordinaer) {
            text(
                bokmal { + "ordinær sats" },
                nynorsk { + "ordinær sats" },
                english { + "ordinary rate" },
            )
        }
    }
}

Se: TextScope

Bruke TextOnlyPhrase

paragraph {
    text(
        bokmal { + "Du får utbetalt garantipensjon etter " },
        nynorsk { + "Du får utbetalt garantipensjon etter " },
        english { + "You will receive guaranteed pension at the " },
    )
    includePhrase(satsType)
    text(
        bokmal { + "." },
        nynorsk { + "." },
        english { + "." },
    )
}