rendered = jinja.render(template, context.getVariables()); } catch (FatalTemplateErrorsException fte) { List<TemplateError> templateErrors = (List<TemplateError>) fte.getErrors();
@Test public void itAvoidsSimpleExtendsCycles() throws IOException { try { jinjava.render(locator.fixture("extends-self.jinja"), new HashMap<String, Object>()); fail("expected extends tag cycle exception"); } catch (FatalTemplateErrorsException e) { TagCycleException cycleException = (TagCycleException) e.getErrors().iterator().next().getException(); assertThat(cycleException.getPath()).isEqualTo("extends-self.jinja"); } }
@Test public void itAvoidsNestedExtendsCycles() throws IOException { try { jinjava.render(locator.fixture("a-extends-b.jinja"), new HashMap<String, Object>()); fail("expected extends tag cycle exception"); } catch (FatalTemplateErrorsException e) { TagCycleException cycleException = (TagCycleException) e.getErrors().iterator().next().getException(); assertThat(cycleException.getPath()).isEqualTo("b-extends-a.jinja"); } }
@Test public void itAvoidsSimpleExtendsCycles() throws IOException { try { jinjava.render(locator.fixture("extends-self.jinja"), new HashMap<String, Object>()); fail("expected extends tag cycle exception"); } catch (FatalTemplateErrorsException e) { TagCycleException cycleException = (TagCycleException) e.getErrors().iterator().next().getException(); assertThat(cycleException.getPath()).isEqualTo("extends-self.jinja"); } }
@Test public void itAvoidsNestedExtendsCycles() throws IOException { try { jinjava.render(locator.fixture("a-extends-b.jinja"), new HashMap<String, Object>()); fail("expected extends tag cycle exception"); } catch (FatalTemplateErrorsException e) { TagCycleException cycleException = (TagCycleException) e.getErrors().iterator().next().getException(); assertThat(cycleException.getPath()).isEqualTo("b-extends-a.jinja"); } }
private static Errors unwrapJinjaTemplateErrorException(FatalTemplateErrorsException e, String location) { Errors errors = new Errors(); for (TemplateError templateError : e.getErrors()) { if (templateError.getException() instanceof TemplateRenderException) { TemplateRenderException tre = (TemplateRenderException) templateError.getException();