diff --git a/pebble/src/test/java/com/mitchellbosecke/pebble/IncludeWithParameterTest.java b/pebble/src/test/java/com/mitchellbosecke/pebble/IncludeWithParameterTest.java index 1e8c6d3c8..eff1c6574 100644 --- a/pebble/src/test/java/com/mitchellbosecke/pebble/IncludeWithParameterTest.java +++ b/pebble/src/test/java/com/mitchellbosecke/pebble/IncludeWithParameterTest.java @@ -1,17 +1,15 @@ package com.mitchellbosecke.pebble; +import static org.junit.jupiter.api.Assertions.assertEquals; + import com.mitchellbosecke.pebble.error.PebbleException; import com.mitchellbosecke.pebble.template.PebbleTemplate; - -import org.junit.jupiter.api.Test; - import java.io.IOException; import java.io.StringWriter; import java.io.Writer; import java.util.HashMap; import java.util.Map; - -import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.Test; /** * This class tests if includes with parameters work. @@ -59,4 +57,23 @@ void testIncludeWithParametersIsolated() throws PebbleException, IOException { } + @Test + void testIncludeWithParameterObject() throws PebbleException, IOException { + + PebbleEngine pebble = new PebbleEngine.Builder().strictVariables(false).build(); + PebbleTemplate template = pebble + .getTemplate("templates/template.includeWithParameterObject1.peb"); + Map context = new HashMap<>(); + context.put("object", new TestObject()); + + Writer writer = new StringWriter(); + template.evaluate(writer, context); + + assertEquals("Hello title", writer.toString()); + } + + public static class TestObject { + + public String title = "title"; + } } diff --git a/pebble/src/test/resources/templates/template.includeWithParameterObject1.peb b/pebble/src/test/resources/templates/template.includeWithParameterObject1.peb new file mode 100644 index 000000000..5fd7e33e4 --- /dev/null +++ b/pebble/src/test/resources/templates/template.includeWithParameterObject1.peb @@ -0,0 +1,2 @@ +{# used by IncludeWithParameterTest.testIncludeWithParameterObject #} +{% include './template.includeWithParameterObject2.peb' with { 'sub' : object } %} \ No newline at end of file diff --git a/pebble/src/test/resources/templates/template.includeWithParameterObject2.peb b/pebble/src/test/resources/templates/template.includeWithParameterObject2.peb new file mode 100644 index 000000000..03f7c5f9d --- /dev/null +++ b/pebble/src/test/resources/templates/template.includeWithParameterObject2.peb @@ -0,0 +1 @@ +Hello {{ sub.title }} \ No newline at end of file