Search in sources :

Example 81 with PyExpr

use of com.google.template.soy.pysrc.restricted.PyExpr in project closure-templates by google.

the class GenPyExprsVisitorTest method testCss.

@Test
public void testCss() {
    assertThatSoyExpr("{css('primary')}").compilesTo(new PyExpr("runtime.get_css_name('primary')", Integer.MAX_VALUE));
    assertThatSoyExpr("{@param foo:?}\n{css($foo, 'bar')}").compilesTo(new PyExpr("runtime.get_css_name(data.get('foo'), 'bar')", Integer.MAX_VALUE));
}
Also used : PyExpr(com.google.template.soy.pysrc.restricted.PyExpr) Test(org.junit.Test)

Example 82 with PyExpr

use of com.google.template.soy.pysrc.restricted.PyExpr in project closure-templates by google.

the class GenPyExprsVisitorTest method testSimpleMsgFallbackGroupNodeWithOneNode.

@Test
public void testSimpleMsgFallbackGroupNodeWithOneNode() {
    String soyCode = "{msg meaning=\"verb\" desc=\"Used as a verb.\"}\n" + "  Archive\n" + "{/msg}\n";
    String expectedPyCode = "translator_impl.render_literal(" + "translator_impl.prepare_literal(" + "###, " + "'Archive'))";
    assertThatSoyExpr(soyCode).compilesTo(new PyExpr(expectedPyCode, Integer.MAX_VALUE));
}
Also used : PyExpr(com.google.template.soy.pysrc.restricted.PyExpr) Test(org.junit.Test)

Aggregations

PyExpr (com.google.template.soy.pysrc.restricted.PyExpr)82 Test (org.junit.Test)58 PyStringExpr (com.google.template.soy.pysrc.restricted.PyStringExpr)21 PyFunctionExprBuilder (com.google.template.soy.pysrc.restricted.PyFunctionExprBuilder)6 LinkedHashMap (java.util.LinkedHashMap)4 SoyPySrcPrintDirective (com.google.template.soy.pysrc.restricted.SoyPySrcPrintDirective)3 SoyPrintDirective (com.google.template.soy.shared.restricted.SoyPrintDirective)3 SoyNode (com.google.template.soy.soytree.SoyNode)3 ExprNode (com.google.template.soy.exprtree.ExprNode)2 ExprRootNode (com.google.template.soy.exprtree.ExprRootNode)2 PyListExpr (com.google.template.soy.pysrc.restricted.PyListExpr)2 MsgPluralNode (com.google.template.soy.soytree.MsgPluralNode)2 PrintNode (com.google.template.soy.soytree.PrintNode)2 SoyFileSetNode (com.google.template.soy.soytree.SoyFileSetNode)2 ParentSoyNode (com.google.template.soy.soytree.SoyNode.ParentSoyNode)2 Supplier (com.google.common.base.Supplier)1 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Truth.assertThat (com.google.common.truth.Truth.assertThat)1