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

liqp.blocks.Ifchanged Maven / Gradle / Ivy

package liqp.blocks;

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

import java.util.*;

public class Ifchanged extends Block {

    /*
        {% for product in products %}

          {% ifchanged %}

{{ product.created_at | date:"%w" }}

{% endifchanged %}

{{ product.title }}

... {% endfor %} */ @Override public Object render(TemplateContext context, LNode... nodes) { if (nodes == null || nodes.length == 0) { return null; } Object rendered = nodes[0].render(context); Map registryMap = context.getRegistry(TemplateContext.REGISTRY_IFCHANGED); if (!Objects.equals(rendered, registryMap.get(TemplateContext.REGISTRY_IFCHANGED))) { registryMap.put(TemplateContext.REGISTRY_IFCHANGED, rendered); return rendered; } else { return null; } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy