Java Code Examples for com.hubspot.jinjava.interpret.JinjavaInterpreter#popCurrent()

The following examples show how to use com.hubspot.jinjava.interpret.JinjavaInterpreter#popCurrent() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MacroTagTest.java    From jinjava with Apache License 2.0 6 votes vote down vote up
@Test
public void itAllowsMacroRecursionWhenEnabledInConfiguration() throws IOException {
  // I need a different configuration here therefore
  interpreter =
    new Jinjava(JinjavaConfig.newBuilder().withEnableRecursiveMacroCalls(true).build())
    .newInterpreter();
  JinjavaInterpreter.pushCurrent(interpreter);

  try {
    String template = fixtureText("ending-recursion");
    String out = interpreter.render(template);
    assertThat(interpreter.getErrorsCopy()).isEmpty();
    assertThat(out).contains("Hello Hello Hello Hello Hello");
  } finally {
    // and I need to cleanup my mess...
    JinjavaInterpreter.popCurrent();
  }
}
 
Example 2
Source File: MacroTagTest.java    From jinjava with Apache License 2.0 6 votes vote down vote up
@Test
public void itAllowsMacroRecursionWithMaxDepth() throws IOException {
  interpreter =
    new Jinjava(
      JinjavaConfig
        .newBuilder()
        .withEnableRecursiveMacroCalls(true)
        .withMaxMacroRecursionDepth(10)
        .build()
    )
    .newInterpreter();
  JinjavaInterpreter.pushCurrent(interpreter);

  try {
    String template = fixtureText("ending-recursion");
    String out = interpreter.render(template);
    assertThat(interpreter.getErrorsCopy()).isEmpty();
    assertThat(out).contains("Hello Hello Hello Hello Hello");
  } finally {
    JinjavaInterpreter.popCurrent();
  }
}
 
Example 3
Source File: MacroTagTest.java    From jinjava with Apache License 2.0 6 votes vote down vote up
@Test
public void itAllowsMacroRecursionWithMaxDepthInValidationMode() throws IOException {
  interpreter =
    new Jinjava(
      JinjavaConfig
        .newBuilder()
        .withEnableRecursiveMacroCalls(true)
        .withMaxMacroRecursionDepth(10)
        .withValidationMode(true)
        .build()
    )
    .newInterpreter();
  JinjavaInterpreter.pushCurrent(interpreter);

  try {
    String template = fixtureText("ending-recursion");
    String out = interpreter.render(template);
    assertThat(interpreter.getErrorsCopy()).isEmpty();
    assertThat(out).contains("Hello Hello Hello Hello Hello");
  } finally {
    JinjavaInterpreter.popCurrent();
  }
}
 
Example 4
Source File: MacroTagTest.java    From jinjava with Apache License 2.0 6 votes vote down vote up
@Test
public void itEnforcesMacroRecursionWithMaxDepth() throws IOException {
  interpreter =
    new Jinjava(
      JinjavaConfig
        .newBuilder()
        .withEnableRecursiveMacroCalls(true)
        .withMaxMacroRecursionDepth(2)
        .build()
    )
    .newInterpreter();
  JinjavaInterpreter.pushCurrent(interpreter);

  try {
    String template = fixtureText("ending-recursion");
    String out = interpreter.render(template);
    assertThat(interpreter.getErrorsCopy().get(0).getMessage())
      .contains("Max recursion limit of 2 reached for macro 'hello'");
    assertThat(out).contains("Hello Hello");
  } finally {
    JinjavaInterpreter.popCurrent();
  }
}
 
Example 5
Source File: MacroTagTest.java    From jinjava with Apache License 2.0 4 votes vote down vote up
@After
public void cleanup() {
  JinjavaInterpreter.popCurrent();
}
 
Example 6
Source File: IfTagTest.java    From jinjava with Apache License 2.0 4 votes vote down vote up
@After
public void tearDown() {
  JinjavaInterpreter.popCurrent();
}
 
Example 7
Source File: FromTagTest.java    From jinjava with Apache License 2.0 4 votes vote down vote up
@After
public void cleanup() {
  JinjavaInterpreter.popCurrent();
}
 
Example 8
Source File: ValidationModeTest.java    From jinjava with Apache License 2.0 4 votes vote down vote up
@After
public void tearDown() {
  JinjavaInterpreter.popCurrent();
}
 
Example 9
Source File: ImportTagTest.java    From jinjava with Apache License 2.0 4 votes vote down vote up
@After
public void cleanup() {
  JinjavaInterpreter.popCurrent();
}
 
Example 10
Source File: CallTagTest.java    From jinjava with Apache License 2.0 4 votes vote down vote up
@After
public void cleanup() {
  JinjavaInterpreter.popCurrent();
}
 
Example 11
Source File: DateTimeFormatFilterTest.java    From jinjava with Apache License 2.0 4 votes vote down vote up
@After
public void clearCurrentInterpreter() {
  JinjavaInterpreter.popCurrent();
}
 
Example 12
Source File: ExtendedSyntaxBuilderTest.java    From jinjava with Apache License 2.0 4 votes vote down vote up
@After
public void cleanup() {
  JinjavaInterpreter.popCurrent();
}