Package com.google.template.soy.soytree

Examples of com.google.template.soy.soytree.IfNode


        "  {/if}\n";

    List<StandaloneNode> nodes = parseTemplateBody(templateBody);
    assertEquals(2, nodes.size());

    IfNode in0 = (IfNode) nodes.get(0);
    assertEquals(1, in0.numChildren());
    IfCondNode in0icn0 = (IfCondNode) in0.getChild(0);
    assertEquals("$zoo", in0icn0.getExprText());
    assertEquals(1, in0icn0.numChildren());
    assertEquals("$zoo", ((PrintNode) in0icn0.getChild(0)).getExprText());
    assertTrue(in0icn0.getExprUnion().getExpr().getChild(0) instanceof DataRefNode);

    IfNode in1 = (IfNode) nodes.get(1);
    assertEquals(3, in1.numChildren());
    IfCondNode in1icn0 = (IfCondNode) in1.getChild(0);
    assertEquals("$boo", in1icn0.getExprText());
    assertTrue(in1icn0.getExprUnion().getExpr().getChild(0) instanceof DataRefNode);
    IfCondNode in1icn1 = (IfCondNode) in1.getChild(1);
    assertEquals("$foo.goo > 2", in1icn1.getExprText());
    assertTrue(in1icn1.getExprUnion().getExpr().getChild(0) instanceof GreaterThanOpNode);
    assertEquals("", ((IfElseNode) in1.getChild(2)).getCommandText());
    assertEquals("{if $boo}Blah{elseif $foo.goo > 2}{$moo}{else}Blah {$moo}{/if}",
                 in1.toSourceString());
  }
View Full Code Here


    ForeachNonemptyNode fn1fnn0 = (ForeachNonemptyNode) fn1.getChild(0);
    assertEquals("boo", fn1fnn0.getVarName());
    assertEquals("$foo.booze", fn1fnn0.getExprText());
    assertEquals("boo", fn1fnn0.getVarName());
    assertEquals(4, fn1fnn0.numChildren());
    IfNode fn1fnn0in = (IfNode) fn1fnn0.getChild(3);
    assertEquals(1, fn1fnn0in.numChildren());
    assertEquals("not isLast($boo)", ((IfCondNode) fn1fnn0in.getChild(0)).getExprText());

    ForeachIfemptyNode fn1fin1 = (ForeachIfemptyNode) fn1.getChild(1);
    assertEquals(1, fn1fin1.numChildren());
    assertEquals("Sorry, no booze.", ((RawTextNode) fn1fin1.getChild(0)).getRawText());
  }
View Full Code Here

    SoyFileSetNode soyTree = SharedTestUtils.parseSoyFiles(testFileContent);

    TemplateNode template = soyTree.getChild(0).getChild(0);
    PrintNode a = (PrintNode) template.getChild(0);
    PrintNode bc = (PrintNode) template.getChild(1);
    IfNode ifNode = (IfNode) template.getChild(2);
    IfCondNode ifCondNode = (IfCondNode) ifNode.getChild(0);
    PrintNode e = (PrintNode) ifCondNode.getChild(0);
    ForeachNode foreachNode = (ForeachNode) ifCondNode.getChild(1);
    ForeachNonemptyNode foreachNonemptyNode = (ForeachNonemptyNode) foreachNode.getChild(0);
    PrintNode f = (PrintNode) foreachNonemptyNode.getChild(0);
    PrintNode gh = (PrintNode) foreachNonemptyNode.getChild(1);
View Full Code Here

TOP

Related Classes of com.google.template.soy.soytree.IfNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.