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

com.github.mustachejava.codes.NotIterableCode Maven / Gradle / Ivy

There is a newer version: 0.9.14
Show newest version
package com.github.mustachejava.codes;

import com.github.mustachejava.DefaultMustacheFactory;
import com.github.mustachejava.Iteration;
import com.github.mustachejava.Mustache;
import com.github.mustachejava.TemplateContext;

import java.io.Writer;

/**
 * Runs the enclosed template once if the value is falsey.
 */
public class NotIterableCode extends DefaultCode implements Iteration {

  public NotIterableCode(TemplateContext templateContext, DefaultMustacheFactory cf, Mustache mustache, String variable) {
    super(templateContext, cf.getObjectHandler(), mustache, variable, "^");
  }

  @Override
  public Writer execute(Writer writer, Object[] scopes) {
    return appendText(oh.falsey(this, writer, get(scopes), scopes));
  }

  @Override
  public Writer next(Writer writer, Object object, Object[] scopes) {
    return run(writer, scopes);
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy