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

liqp.blocks.Unless Maven / Gradle / Ivy

Go to download

A Java implementation of the Liquid templating engine backed up by an ANTLR grammar.

The newest version!
package liqp.blocks;

import liqp.TemplateContext;
import liqp.nodes.LNode;

public class Unless extends Block {

    /*
     * Mirror of if statement
     */
    @Override
    public Object render(TemplateContext context, LNode... nodes) {

        for (int i = 0; i < nodes.length - 1; i += 2) {

            Object exprNodeValue = nodes[i].render(context);
            LNode blockNode = nodes[i + 1];

            if (!super.asBoolean(exprNodeValue)) {
                return blockNode.render(context);
            }
        }

        return "";
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy