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

io.quarkus.qute.runtime.extensions.ConfigTemplateExtensions Maven / Gradle / Ivy

package io.quarkus.qute.runtime.extensions;

import static io.quarkus.qute.TemplateExtension.ANY;
import static io.quarkus.qute.TemplateExtension.DEFAULT_PRIORITY;

import java.util.Optional;

import javax.enterprise.inject.Vetoed;

import org.eclipse.microprofile.config.ConfigProvider;

import io.quarkus.qute.Results.Result;
import io.quarkus.qute.TemplateExtension;

@Vetoed // Make sure no bean is created from this class
public class ConfigTemplateExtensions {

    static final String CONFIG = "config";

    // {config:foo} or {config:['bar.baz']}
    @TemplateExtension(namespace = CONFIG, matchName = ANY)
    static Object getConfigProperty(String propertyName) {
        return property(propertyName);
    }

    // {config:property(foo.getPropertyName())}
    @TemplateExtension(namespace = CONFIG, priority = DEFAULT_PRIORITY + 1)
    static Object property(String propertyName) {
        Optional val = ConfigProvider.getConfig().getOptionalValue(propertyName, String.class);
        return val.isPresent() ? val.get() : Result.NOT_FOUND;
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy