/** * Create a new Jinjava processor instance with the default global config */ public Jinjava() { this(new JinjavaConfig()); }
public JinjavaEngine(JinjavaConfig jinjavaConfig, ResourceLocator resourceLocator) { jinjava = new Jinjava(jinjavaConfig); jinjava.setResourceLocator(resourceLocator); context = jinjava.getGlobalContext(); }
/** * Render the given template using the given context bindings. This method returns some metadata about the render process, including any errors which may have been encountered such as unknown variables or syntax errors. This method will * not throw any exceptions; it is up to the caller to inspect the renderResult.errors collection if necessary / desired. * * @param template * jinja source template * @param bindings * map of objects to put into scope for this rendering action * @return result object containing rendered output, render context, and any encountered errors */ public RenderResult renderForResult(String template, Map<String, ?> bindings) { return renderForResult(template, bindings, globalConfig); }
@Before public void setup() { validationFilter = new ValidationFilter(); ELFunctionDefinition validationFunction = new ELFunctionDefinition("", "validation_test", ValidationModeTest.class, "validationTestFunction"); jinjava = new Jinjava(); jinjava.getGlobalContext().registerFilter(validationFilter); jinjava.getGlobalContext().registerFunction(validationFunction); interpreter = jinjava.newInterpreter(); context = interpreter.getContext(); validatingInterpreter = new JinjavaInterpreter(jinjava, context, JinjavaConfig.newBuilder().withValidationMode(true).build()); JinjavaInterpreter.pushCurrent(interpreter); }
@Test public void trimAndLstripBlocks() { interpreter = new Jinjava(JinjavaConfig.newBuilder().withLstripBlocks(true).withTrimBlocks(true).build()).newInterpreter(); assertThat(interpreter.render(parse("parse/tokenizer/whitespace-tags.jinja"))) .isEqualTo("<div>\n" + " yay\n" + "</div>\n"); }
@Before public void setup() { locator = new ExtendsTagTestResourceLocator(); JinjavaConfig conf = new JinjavaConfig(); jinjava = new Jinjava(conf); jinjava.setResourceLocator(locator); }
@Before public void setUp() { JinjavaConfig.Builder builder = JinjavaConfig.newBuilder(); builder.withFailOnUnknownTokens(true); JinjavaConfig config = builder.build(); jinjava = new Jinjava(config); }
/** * Creates a new interpreter instance using the global context and global config * * @return a new interpreter instance */ public JinjavaInterpreter newInterpreter() { return new JinjavaInterpreter(this, this.getGlobalContext(), this.getGlobalConfig()); }
private JinjavaConfig trimBlocksConfig() { return JinjavaConfig.newBuilder().withTrimBlocks(true).build(); }
@Before public void setup() { jinjava = new Jinjava(); interpreter = jinjava.newInterpreter(); }
@Before public void setup() { config = JinjavaConfig.newBuilder().build(); }
public String getResource(String resource) throws IOException { return application.getResourceLocator().getString(resource, config.getCharset(), this); }
public boolean isValidationMode() { return config.isValidationMode(); }
public static Builder newBuilder() { return new Builder(); }
@Before public void setup() { locator = new ExtendsTagTestResourceLocator(); JinjavaConfig conf = new JinjavaConfig(); jinjava = new Jinjava(conf); jinjava.setResourceLocator(locator); }
@Before public void setUp() { JinjavaConfig.Builder builder = JinjavaConfig.newBuilder(); builder.withFailOnUnknownTokens(true); JinjavaConfig config = builder.build(); jinjava = new Jinjava(config); }
private JinjavaConfig trimBlocksConfig() { return JinjavaConfig.newBuilder().withTrimBlocks(true).build(); }
@Before public void setup() { config = JinjavaConfig.newBuilder().build(); }
public JinjavaEngine() { this(new JinjavaConfig()); }
public JinjavaConfig build() { return new JinjavaConfig(charset, locale, timeZone, maxRenderDepth, disabled, trimBlocks, lstripBlocks, readOnlyResolver, enableRecursiveMacroCalls, failOnUnknownTokens, maxOutputSize, nestedInterpretationEnabled, randomNumberGeneratorStrategy, validationMode, maxStringLength); }