liqp.nodes.ContainsNode Maven / Gradle / Ivy
package liqp.nodes;
import liqp.LValue;
import liqp.TemplateContext;
import liqp.parser.Inspectable;
import liqp.parser.LiquidSupport;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class ContainsNode extends LValue implements LNode {
private LNode lhs;
private LNode rhs;
public ContainsNode(LNode lhs, LNode rhs) {
this.lhs = lhs;
this.rhs = rhs;
}
@Override
public Object render(TemplateContext context) {
Object collection = lhs.render(context);
Object needle = rhs.render(context);
if (collection instanceof Inspectable) {
LiquidSupport evaluated = context.renderSettings.evaluate(context.parseSettings.mapper, collection);
collection = evaluated.toLiquid();
}
if (isMap(collection)) {
collection = asMap(collection).keySet().toArray();
}
if(super.isArray(collection)) {
Object[] array = super.asArray(collection, context);
List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy