Search in sources :

Example 1 with LoopVar

use of com.google.template.soy.soytree.defn.LoopVar in project closure-templates by google.

the class EvalVisitor method visitIndexFunction.

private SoyValue visitIndexFunction(FunctionNode node) {
    int localVarIndex;
    try {
        VarRefNode dataRef = (VarRefNode) node.getChild(0);
        localVarIndex = env.getIndex((LoopVar) dataRef.getDefnDecl());
    } catch (Exception e) {
        throw RenderException.create("Failed to evaluate function call " + node.toSourceString() + ".", e);
    }
    return convertResult(localVarIndex);
}
Also used : LoopVar(com.google.template.soy.soytree.defn.LoopVar) VarRefNode(com.google.template.soy.exprtree.VarRefNode) IOException(java.io.IOException) SoyDataException(com.google.template.soy.data.SoyDataException)

Example 2 with LoopVar

use of com.google.template.soy.soytree.defn.LoopVar in project closure-templates by google.

the class RenderVisitor method executeForeachBody.

private void executeForeachBody(ForNonemptyNode child, int i, SoyValueProvider value, int size) {
    LoopVar var = child.getVar();
    env.bind(var, value);
    env.bindCurrentIndex(var, i);
    env.bindIsLast(var, size - 1 == i);
    visitChildren(child);
}
Also used : LoopVar(com.google.template.soy.soytree.defn.LoopVar)

Example 3 with LoopVar

use of com.google.template.soy.soytree.defn.LoopVar in project closure-templates by google.

the class EvalVisitor method visitIsFirstFunction.

private SoyValue visitIsFirstFunction(FunctionNode node) {
    int localVarIndex;
    try {
        VarRefNode dataRef = (VarRefNode) node.getChild(0);
        localVarIndex = env.getIndex((LoopVar) dataRef.getDefnDecl());
    } catch (Exception e) {
        throw RenderException.create("Failed to evaluate function call " + node.toSourceString() + ".", e);
    }
    return convertResult(localVarIndex == 0);
}
Also used : LoopVar(com.google.template.soy.soytree.defn.LoopVar) VarRefNode(com.google.template.soy.exprtree.VarRefNode) IOException(java.io.IOException) SoyDataException(com.google.template.soy.data.SoyDataException)

Example 4 with LoopVar

use of com.google.template.soy.soytree.defn.LoopVar in project closure-templates by google.

the class EvalVisitor method visitIsLastFunction.

private SoyValue visitIsLastFunction(FunctionNode node) {
    boolean isLast;
    try {
        VarRefNode dataRef = (VarRefNode) node.getChild(0);
        isLast = env.isLast((LoopVar) dataRef.getDefnDecl());
    } catch (Exception e) {
        throw RenderException.create("Failed to evaluate function call " + node.toSourceString() + ".", e);
    }
    return convertResult(isLast);
}
Also used : LoopVar(com.google.template.soy.soytree.defn.LoopVar) VarRefNode(com.google.template.soy.exprtree.VarRefNode) IOException(java.io.IOException) SoyDataException(com.google.template.soy.data.SoyDataException)

Aggregations

LoopVar (com.google.template.soy.soytree.defn.LoopVar)4 SoyDataException (com.google.template.soy.data.SoyDataException)3 VarRefNode (com.google.template.soy.exprtree.VarRefNode)3 IOException (java.io.IOException)3