io.quarkus.qute.runtime.extensions.ConfigTemplateExtensions Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of quarkus-qute Show documentation
Show all versions of quarkus-qute Show documentation
Offer templating support for web, email, etc in a build time, type-safe way
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;
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() : Results.NotFound.from(propertyName);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy