public class Jinjava extends Object
Jinjava jinjava = new Jinjava(); Map<String, Object> context = new HashMap<>(); context.put("name", "Jared"); String template = "Hello, {{ name }}"; String renderedTemplate = jinjava.render(template, context);
Constructor and Description |
---|
Jinjava()
Create a new Jinjava processor instance with the default global config
|
Jinjava(JinjavaConfig globalConfig)
Create a new jinjava processor instance with the specified global config
|
Modifier and Type | Method and Description |
---|---|
javax.el.ExpressionFactory |
getExpressionFactory() |
JinjavaConfig |
getGlobalConfig() |
Context |
getGlobalContext()
The global render context includes such things as the base set of tags, filters, exp tests and functions,
used as a base by all render operations performed by this instance
|
JinjavaDoc |
getJinjavaDoc() |
ResourceLocator |
getResourceLocator() |
JinjavaInterpreter |
newInterpreter()
Creates a new interpreter instance using the global context and global config
|
String |
render(String template,
Map<String,?> bindings)
Render the given template using the given context bindings.
|
RenderResult |
renderForResult(String template,
Map<String,?> bindings)
Render the given template using the given context bindings.
|
RenderResult |
renderForResult(String template,
Map<String,?> bindings,
JinjavaConfig renderConfig)
Render the given template using the given context bindings.
|
void |
setResourceLocator(ResourceLocator resourceLocator)
Set the object responsible for locating templates referenced in other templates
|
public Jinjava()
public Jinjava(JinjavaConfig globalConfig)
globalConfig
- used for all render operations performed by this processor instancepublic void setResourceLocator(ResourceLocator resourceLocator)
resourceLocator
- the locator to use for loading all templatespublic javax.el.ExpressionFactory getExpressionFactory()
public JinjavaConfig getGlobalConfig()
public Context getGlobalContext()
public ResourceLocator getResourceLocator()
public JinjavaDoc getJinjavaDoc()
public String render(String template, Map<String,?> bindings)
template
- jinja source templatebindings
- map of objects to put into scope for this rendering actionInterpretException
- if any syntax errors were encountered during renderingpublic RenderResult renderForResult(String template, Map<String,?> bindings)
template
- jinja source templatebindings
- map of objects to put into scope for this rendering actionpublic RenderResult renderForResult(String template, Map<String,?> bindings, JinjavaConfig renderConfig)
template
- jinja source templatebindings
- map of objects to put into scope for this rendering actionrenderConfig
- used to override specific config values for this render operationpublic JinjavaInterpreter newInterpreter()
Copyright © 2015. All Rights Reserved.