diff --git a/.build-jdk17 b/.build-jdk17 new file mode 100644 index 000000000..e69de29bb diff --git a/src/main/java/com/hubspot/jinjava/lib/filter/PrettyPrintFilter.java b/src/main/java/com/hubspot/jinjava/lib/filter/PrettyPrintFilter.java index a0777f701..8132aaeae 100644 --- a/src/main/java/com/hubspot/jinjava/lib/filter/PrettyPrintFilter.java +++ b/src/main/java/com/hubspot/jinjava/lib/filter/PrettyPrintFilter.java @@ -10,6 +10,7 @@ import com.hubspot.jinjava.objects.date.PyishDate; import java.util.Map; import java.util.Objects; +import java.util.TreeMap; @JinjavaDoc( value = "Pretty print a variable. Useful for debugging.", @@ -45,10 +46,12 @@ public Object filter(Object var, JinjavaInterpreter interpreter, String... args) var instanceof String || var instanceof Number || var instanceof PyishDate || - var instanceof Iterable || - var instanceof Map + var instanceof Iterable ) { varStr = Objects.toString(var); + } else if (var instanceof Map) { + TreeMap map = new TreeMap((Map) var); + varStr = Objects.toString(map); } else { try { varStr = diff --git a/src/test/java/com/hubspot/jinjava/lib/filter/PrettyPrintFilterTest.java b/src/test/java/com/hubspot/jinjava/lib/filter/PrettyPrintFilterTest.java index 22cf1b650..2f1c1195b 100644 --- a/src/test/java/com/hubspot/jinjava/lib/filter/PrettyPrintFilterTest.java +++ b/src/test/java/com/hubspot/jinjava/lib/filter/PrettyPrintFilterTest.java @@ -52,8 +52,8 @@ public void ppPyDate() { @Test public void ppMap() { - assertThat(f.filter(ImmutableMap.of("a", "foo", "b", "bar"), null)) - .isEqualTo("{% raw %}(RegularImmutableMap: {a=foo, b=bar}){% endraw %}"); + assertThat(f.filter(ImmutableMap.of("b", "foo", "a", "bar"), null)) + .isEqualTo("{% raw %}(RegularImmutableMap: {a=bar, b=foo}){% endraw %}"); } @Test