Search in sources :

Example 6 with MsgSelectNode

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

the class MsgCompiler method putSelectPartIntoMap.

private void putSelectPartIntoMap(Expression mapExpression, MsgNode originalMsg, Map<String, Statement> placeholderNameToPutStatement, SoyMsgSelectPart select) {
    MsgSelectNode repSelectNode = originalMsg.getRepSelectNode(select.getSelectVarName());
    if (!placeholderNameToPutStatement.containsKey(select.getSelectVarName())) {
        Label reattachPoint = new Label();
        Expression value = soyNodeCompiler.compileToString(repSelectNode.getExpr(), reattachPoint);
        placeholderNameToPutStatement.put(select.getSelectVarName(), putToMap(mapExpression, select.getSelectVarName(), value).labelStart(reattachPoint));
    }
    // Recursively visit select cases
    for (Case<String> caseOrDefault : select.getCases()) {
        putPlaceholdersIntoMap(mapExpression, originalMsg, caseOrDefault.parts(), placeholderNameToPutStatement);
    }
}
Also used : SoyExpression(com.google.template.soy.jbcsrc.restricted.SoyExpression) Expression(com.google.template.soy.jbcsrc.restricted.Expression) Label(org.objectweb.asm.Label) MsgSelectNode(com.google.template.soy.soytree.MsgSelectNode)

Aggregations

MsgSelectNode (com.google.template.soy.soytree.MsgSelectNode)6 MsgPlaceholderNode (com.google.template.soy.soytree.MsgPlaceholderNode)4 RawTextNode (com.google.template.soy.soytree.RawTextNode)4 StandaloneNode (com.google.template.soy.soytree.SoyNode.StandaloneNode)4 MsgSelectCaseNode (com.google.template.soy.soytree.MsgSelectCaseNode)3 MsgSelectDefaultNode (com.google.template.soy.soytree.MsgSelectDefaultNode)3 MsgFallbackGroupNode (com.google.template.soy.soytree.MsgFallbackGroupNode)2 MsgNode (com.google.template.soy.soytree.MsgNode)2 MsgPluralNode (com.google.template.soy.soytree.MsgPluralNode)2 Test (org.junit.Test)2 ImmutableList (com.google.common.collect.ImmutableList)1 Expression (com.google.template.soy.jbcsrc.restricted.Expression)1 SoyExpression (com.google.template.soy.jbcsrc.restricted.SoyExpression)1 SoyMsgPart (com.google.template.soy.msgs.restricted.SoyMsgPart)1 SoyMsgPlaceholderPart (com.google.template.soy.msgs.restricted.SoyMsgPlaceholderPart)1 PyExpr (com.google.template.soy.pysrc.restricted.PyExpr)1 PyStringExpr (com.google.template.soy.pysrc.restricted.PyStringExpr)1 AbstractParentSoyNode (com.google.template.soy.soytree.AbstractParentSoyNode)1 CallNode (com.google.template.soy.soytree.CallNode)1 MsgHtmlTagNode (com.google.template.soy.soytree.MsgHtmlTagNode)1