All Downloads are FREE. Search and download functionalities are using the official Maven repository.

invirt.pebble.functions.utils.kt Maven / Gradle / Ivy

There is a newer version: 0.10.11
Show newest version
package invirt.pebble.functions

import invirt.http4k.InvirtRequestContext
import invirt.utils.minorUnitToString
import java.util.*

val currencyFromMinorUnitFunction = pebbleFunction("currencyFromMinorUnit", "minorUnitAmount", "currency") {
    val minorUnitAmount = (args["minorUnitAmount"]!! as Number).toLong()
    Currency.getInstance(args["currency"]!! as String).minorUnitToString(minorUnitAmount)
}

val errorsFunction = pebbleFunction("errors") {
    InvirtRequestContext.errors
}

/**
 * Used mainly for access inside macros, otherwise request is exposed
 * in the current model for a template
 */
val requestFunction = pebbleFunction("request") {
    InvirtRequestContext.currentRequest
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy