How to reproduce:
1. create a soy template containing a number format directive
{namespace test.template}
/**
* Currency Test Template
* @param cost
*/
{template .currencyTest}
Cost: {$cost |formatNum:'currency'}
{/template}
2. render the template
Template template = new Template(soyUrl);
template.render("test.template", ".currencyTest", ImmutableMap.<String,
?>of("cost", 42.17f));
3. observe the following exception when executing the aforementioned code
snippet:
java.lang.IllegalArgumentException: Unrecognized Number Format Type: {0}
at com.google.template.soy.i18ndirectives.FormatNumDirective.apply(FormatNumDirective.java:95)
at com.google.template.soy.tofu.restricted.SoyAbstractTofuPrintDirective.applyForTofu(SoyAbstractTofuPrintDirective.java:33)
at com.google.template.soy.tofu.internal.TofuRenderVisitor.applyDirective(TofuRenderVisitor.java:109)
at com.google.template.soy.sharedpasses.render.RenderVisitor.visitPrintNode(RenderVisitor.java:256)
at com.google.template.soy.soytree.AbstractSoyNodeVisitor.visit(AbstractSoyNodeVisitor.java:85)
at com.google.template.soy.soytree.AbstractSoyNodeVisitor.visit(AbstractSoyNodeVisitor.java:55)
at com.google.template.soy.basetree.AbstractNodeVisitor.visitChildren(AbstractNodeVisitor.java:59)
at com.google.template.soy.soytree.AbstractSoyNodeVisitor.visitChildren(AbstractSoyNodeVisitor.java:126)
at com.google.template.soy.sharedpasses.render.RenderVisitor.visitBlockHelper(RenderVisitor.java:648)
at com.google.template.soy.sharedpasses.render.RenderVisitor.visitTemplateNode(RenderVisitor.java:211)
at com.google.template.soy.soytree.AbstractSoyNodeVisitor.visitTemplateBasicNode(AbstractSoyNodeVisitor.java:157)
at com.google.template.soy.soytree.AbstractSoyNodeVisitor.visit(AbstractSoyNodeVisitor.java:65)
at com.google.template.soy.soytree.AbstractSoyNodeVisitor.visit(AbstractSoyNodeVisitor.java:55)
at com.google.template.soy.basetree.AbstractNodeVisitor.exec(AbstractNodeVisitor.java:40)
at com.google.template.soy.tofu.internal.BaseTofu.renderMainHelper(BaseTofu.java:383)
at com.google.template.soy.tofu.internal.BaseTofu.renderMain(BaseTofu.java:341)
at com.google.template.soy.tofu.internal.BaseTofu.renderMain(BaseTofu.java:292)
at com.google.template.soy.tofu.internal.BaseTofu.access$000(BaseTofu.java:63)
at com.google.template.soy.tofu.internal.BaseTofu$RendererImpl.render(BaseTofu.java:466)
The expected output would be a return value of "Cost: $42.17"
This happens with soy-2012-12-21
on Windows 7 x64
with Java 1.7.0_60_x64
The root cause seems to be the formatType check in
com.google.template.soy.i18ndirectives.FormatNumDirective.apply(SoyData,
List<SoyData>)
The formatType checks at lines 86 to 92 should be done with String.equals and
not with ==
Original issue reported on code.google.com by cpwr.lab...@gmail.com on 25 Feb 2015 at 1:49
Original issue reported on code.google.com by
cpwr.lab...@gmail.com
on 25 Feb 2015 at 1:49