Add a test explaining that why filterHtmlAttributes is preventing logging functions to be evaluated.
@@ -118,7 +118,7 @@ public final class VeLoggingTest {
@Override
public String getPlaceholder() {
- return "depth_placholder";
+ return "depth_placeholder";
}
}
@@ -220,6 +220,36 @@ public final class VeLoggingTest {
.isEqualTo("<div data-depth=0></div><div data-depth=1></div><div data-depth=0></div>");
}
+ @Test
+ public void testLogging_loggingFunction_let() throws Exception {
+ StringBuilder sb = new StringBuilder();
+ TestLogger testLogger = new TestLogger();
+ renderTemplate(
+ OutputAppendable.create(sb, testLogger),
+ ""
+ + "{let $letAttribute kind=\"attributes\"}\n"
+ + " data-depth-1={depth()}\n"
+ + "{/let}\n"
+ + "{velog Foo}\n"
+ + " <div data-depth={depth()}>\n"
+ + " {let $letAttribute2 kind=\"attributes\"}\n"
+ + " data-depth-2={depth()}\n"
+ + " {/let}\n"
+ + " {velog Bar}\n"
+ + " <div {$letAttribute} {$letAttribute2}>\n"
+ + " </div>\n"
+ + " {/velog}\n"
+ + " </div>\n"
+ + "{/velog}");
+ assertThat(testLogger.builder.toString()).isEqualTo("velog{id=1}\n velog{id=2}");
+ // TODO(b/18260376): filterHtmlAttributes print directive is preventing the logging functions
+ // to be evaluated. Making it streamable should fix these depth_placeholder.
+ assertThat(sb.toString())
+ .isEqualTo(
+ "<div data-depth=1><div data-depth-1=depth_placeholder "
+ + " data-depth-2=depth_placeholder ></div></div>");
+ }
+
@Test
public void testLogging_loggingFunction_usesPlaceholders() throws Exception {
StringBuilder sb = new StringBuilder();
@@ -231,7 +261,7 @@ public final class VeLoggingTest {
// nothing is logged because no elements were rendered
assertThat(testLogger.builder.toString()).isEqualTo("");
// everything is escaped, and the placeholder is used instead of a 'real value'
- assertThat(sb.toString()).contains("depth_placholder");
+ assertThat(sb.toString()).contains("depth_placeholder");
}
private void renderTemplate(OutputAppendable output, String... templateBodyLines)
