io.quarkus.qute.runtime.extensions.CollectionTemplateExtensions 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 java.util.List;
import javax.enterprise.inject.Vetoed;
import io.quarkus.qute.Results.Result;
import io.quarkus.qute.TemplateExtension;
@Vetoed // Make sure no bean is created from this class
@TemplateExtension
public class CollectionTemplateExtensions {
static Object get(List> list, int index) {
return list.get(index);
}
@TemplateExtension(matchRegex = "\\d{1,10}")
static Object getByIndex(List> list, String index) {
int idx = Integer.parseInt(index);
if (idx >= list.size()) {
// Be consistent with property resolvers
return Result.NOT_FOUND;
}
return list.get(idx);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy