public class DefaultRenderingContext extends Object implements RenderingContext, FunctionExecutor
Constructor and Description |
---|
DefaultRenderingContext(DataContext dataContext,
ResourceLoader resourceLoader,
Appendable out,
FunctionExecutor globalFunctionExecutor,
AutoEscapeOptions autoEscapeOptions) |
Modifier and Type | Method and Description |
---|---|
void |
escape(String name,
String input,
Appendable output)
Escapes some text.
|
Value |
executeFunction(String name,
Value... args)
Lookup a function by name, execute it and return the results.
|
Macro |
findMacro(String name)
Lookup a macro that's already been registered.
|
EscapeMode |
getAutoEscapeMode()
Read the currently set auto escape mode.
|
AutoEscapeOptions |
getAutoEscapeOptions()
Returns the configured AutoEscapeOptions to be used while rendering the current template.
|
DataContext |
getDataContext()
Return the DataContext object associated with this RenderingContext.
|
Iterable<String> |
getIncludedTemplateNames()
Returns the ordered, mutable stack of names of included templates.
|
ResourceLoader |
getResourceLoader()
Returns the ResourceLoader object to use to fetch files needed to render the current template.
|
boolean |
isEscapingFunction(String name)
Look up a function by name, and report whether it is an escaping function.
|
boolean |
isRuntimeAutoEscaping()
Indicates whether runtime auto escaping is in progress.
|
void |
popAutoEscapeMode() |
void |
popEscapingFunction() |
void |
popExecutionContext() |
boolean |
popIncludeStackEntry(String templateName)
Removes an entry with a name of the template from the stack.
|
void |
pushAutoEscapeMode(EscapeMode mode)
Push a new auto escaping mode onto the context.
|
void |
pushEscapingFunction(String name)
Push a new escaping function onto the context.
|
void |
pushExecutionContext(Template template)
Push a new template onto the current execution context.
|
boolean |
pushIncludeStackEntry(String templateName)
Adds an entry with a name of the template to the stack keeping all names of already included
templates.
|
void |
registerMacro(String name,
Macro macro)
Register a macro in the current rendering context.
|
void |
setCurrentPosition(int line,
int column)
Sets the current position in the template.
|
void |
startRuntimeAutoEscaping()
Start an auto escaping context to parse and auto escape template contents as they are being
rendered.
|
void |
stopRuntimeAutoEscaping()
Stop runtime auto escaping.
|
void |
writeEscaped(String text)
Write some text out, using the current escaping function.
|
void |
writeUnescaped(CharSequence text)
Write some text out, without doing any escaping.
|
public static final Logger logger
public DefaultRenderingContext(DataContext dataContext, ResourceLoader resourceLoader, Appendable out, FunctionExecutor globalFunctionExecutor, AutoEscapeOptions autoEscapeOptions)
public Value executeFunction(String name, Value... args)
executeFunction
in interface FunctionExecutor
executeFunction
in interface RenderingContext
public void escape(String name, String input, Appendable output) throws IOException
FunctionExecutor
escape
in interface FunctionExecutor
name
- Strategy for escaping text. If null or "none", text will be left as is.input
- Text to be escaped.output
- Where to write the result to.IOException
public boolean isEscapingFunction(String name)
RenderingContext
isEscapingFunction
in interface FunctionExecutor
isEscapingFunction
in interface RenderingContext
EscapingEvaluator
public void pushEscapingFunction(String name)
RenderingContext
pushEscapingFunction
in interface RenderingContext
RenderingContext.popEscapingFunction()
public void popEscapingFunction()
popEscapingFunction
in interface RenderingContext
RenderingContext.pushEscapingFunction(String)
public void writeEscaped(String text)
RenderingContext
writeEscaped
in interface RenderingContext
RenderingContext.pushEscapingFunction(String)
,
RenderingContext.popEscapingFunction()
public void writeUnescaped(CharSequence text)
RenderingContext
writeUnescaped
in interface RenderingContext
public void pushExecutionContext(Template template)
RenderingContext
pushExecutionContext
in interface RenderingContext
RenderingContext.popExecutionContext()
public void popExecutionContext()
popExecutionContext
in interface RenderingContext
RenderingContext.pushExecutionContext(Template)
public void setCurrentPosition(int line, int column)
RenderingContext
setCurrentPosition
in interface RenderingContext
public void registerMacro(String name, Macro macro)
RenderingContext
registerMacro
in interface RenderingContext
public Macro findMacro(String name)
RenderingContext
findMacro
in interface RenderingContext
public DataContext getDataContext()
RenderingContext
getDataContext
in interface RenderingContext
public ResourceLoader getResourceLoader()
RenderingContext
getResourceLoader
in interface RenderingContext
public AutoEscapeOptions getAutoEscapeOptions()
RenderingContext
getAutoEscapeOptions
in interface RenderingContext
public EscapeMode getAutoEscapeMode()
RenderingContext
getAutoEscapeMode
in interface RenderingContext
public void pushAutoEscapeMode(EscapeMode mode)
RenderingContext
pushAutoEscapeMode
in interface RenderingContext
RenderingContext.popAutoEscapeMode()
public void popAutoEscapeMode()
popAutoEscapeMode
in interface RenderingContext
RenderingContext.pushAutoEscapeMode(com.google.clearsilver.jsilver.autoescape.EscapeMode)
public boolean isRuntimeAutoEscaping()
RenderingContext
isRuntimeAutoEscaping
in interface RenderingContext
RenderingContext.isRuntimeAutoEscaping()
public void startRuntimeAutoEscaping()
startRuntimeAutoEscaping
in interface RenderingContext
JSilverInterpreterException
- if startRuntimeAutoEscaping is called while runtime
autoescaping is already in progress.RenderingContext.stopRuntimeAutoEscaping()
public void stopRuntimeAutoEscaping()
RenderingContext
stopRuntimeAutoEscaping
in interface RenderingContext
RenderingContext.startRuntimeAutoEscaping()
public boolean pushIncludeStackEntry(String templateName)
RenderingContext
pushIncludeStackEntry
in interface RenderingContext
templateName
- name of the template to be added to the stack. If null
a NullPointerException
will be thrown.templateName
was added.public boolean popIncludeStackEntry(String templateName)
RenderingContext
popIncludeStackEntry
in interface RenderingContext
templateName
was on the stack.public Iterable<String> getIncludedTemplateNames()
RenderingContext
getIncludedTemplateNames
in interface RenderingContext
Copyright © 2010–2018 Google. All rights reserved.