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

invirt.pebble.InvirtPebbleExtension.kt Maven / Gradle / Ivy

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

import invirt.pebble.filters.DateWithDaySuffixFilter
import invirt.pebble.functions.*
import invirt.utils.uuid7
import io.pebbletemplates.pebble.extension.AbstractExtension
import io.pebbletemplates.pebble.extension.Filter
import io.pebbletemplates.pebble.extension.Function
import java.time.LocalDate

class InvirtPebbleExtension : AbstractExtension() {

    override fun getFunctions(): Map {
        return listOf(
            pebbleFunction("today") { LocalDate.now() },
            pebbleFunction("uuid") { uuid7() },

            // Utils
            currencyFromMinorUnitFunction,
            errorsFunction,

            // JSON
            jsonFunction,
            jsonArrayFunction,

            // Request
            requestFunction
        ).associateBy { it.name }
    }

    override fun getFilters(): Map {
        return mapOf(
            "dateWithDaySuffix" to DateWithDaySuffixFilter()
        )
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy