public class GlobalRenderContext extends Object
Tagliatelle.createRenderContext()| Modifier and Type | Field and Description |
|---|---|
protected StringBuilder |
buffer |
protected Tagliatelle |
engine |
protected Function<String,String> |
escaper |
protected Map<String,String> |
extraBlocks |
protected sirius.tagliatelle.rendering.StackAllocator |
stack |
protected Map<String,Template> |
templateCache |
| Constructor and Description |
|---|
GlobalRenderContext(Tagliatelle engine)
Creates a new render context.
|
| Modifier and Type | Method and Description |
|---|---|
LocalRenderContext |
createContext(Template template)
Creates a local render context to invoke the given template.
|
String |
emitToString(RenderCall callback)
Emits everything which is invoked from within the callback into an unescaped string.
|
static String |
escapeRAW(String input)
Provides a raw escaper which doesn't alter the input at all.
|
static String |
escapeXML(String input)
Provides a XML escaper which processes XML control characters.
|
Function<String,String> |
getEscaper()
Returns the currently active escaper.
|
String |
getExtraBlock(String name)
Returns the contents for the given extra block, which were create during rendering.
|
List<Object> |
getGlobals()
Provides access to the environment (global variables).
|
protected void |
outputEscaped(String string)
Adds escaped output to the result buffer.
|
protected void |
outputRaw(String string)
Adds unescaped output to the result buffer.
|
protected void |
release(LocalRenderContext renderContext)
Releases the local render context to free up the allocated stack.
|
protected Optional<Template> |
resolve(String templateName)
Resolves the given template.
|
void |
setEscaper(Function<String,String> escaper)
Specifies the escaper to use.
|
void |
storeExtraBlock(String name,
String contents)
Stores the rendering of an extra block.
|
String |
toString() |
protected sirius.tagliatelle.rendering.StackAllocator stack
protected Tagliatelle engine
protected StringBuilder buffer
public GlobalRenderContext(Tagliatelle engine)
Use Tagliatelle.createRenderContext() to obtain an instance.
engine - the global engine instance.protected Optional<Template> resolve(String templateName) throws CompileException
A local cache is maintained so that a previously resolved template is directly re-used and not resolved several times.
templateName - the name of the template to resolveCompileException - in case the resolved template has compile errorsprotected void outputRaw(String string)
string - the string to outputLocalRenderContext.outputRaw(String)protected void outputEscaped(String string)
Utilizes the current escaper to escape the given string.
string - the string to output(String)public void setEscaper(@Nonnull Function<String,String> escaper)
escaper - a mapping function to escape certain characters in strings being output using outputEscaped(String).public Function<String,String> getEscaper()
public static String escapeRAW(String input)
input - the string to outputpublic static String escapeXML(String input)
input - the string to outputContentHelper.escapeXML(Object)public LocalRenderContext createContext(Template template)
template - the template to invokeprotected void release(LocalRenderContext renderContext)
Note that createContext(Template) and release(LocalRenderContext) must be folded appropriately.
renderContext - the context to free uppublic List<Object> getGlobals()
@Nonnull public String getExtraBlock(String name)
Using <i:block> tags at the top level permits to output additional rendering results, next to the main string.
name - the name of the blockpublic String emitToString(RenderCall callback)
callback - the callback which will invoke emitters.Copyright © 2018. All rights reserved.