com.google.clearsilver.jsilver.template
Interface RenderingContext

All Known Implementing Classes:
DefaultRenderingContext

public interface RenderingContext

State that is shared across a template rendering.


Method Summary
 Value executeFunction(String name, Value... args)
          Execute a named function.
 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 escaperName)
          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.
 

Method Detail

executeFunction

Value executeFunction(String name,
                      Value... args)
                      throws JSilverInterpreterException
Execute a named function. Will throw an exception if the function is not found, or the function does not return a value.

Throws:
JSilverInterpreterException

isEscapingFunction

boolean isEscapingFunction(String name)
Look up a function by name, and report whether it is an escaping function. Usually, the output of escaping functions will be written using writeUnescaped() instead of writeEscaped().

See Also:
EscapingEvaluator

writeEscaped

void writeEscaped(String text)
Write some text out, using the current escaping function.

See Also:
pushEscapingFunction(String), popEscapingFunction()

writeUnescaped

void writeUnescaped(CharSequence text)
Write some text out, without doing any escaping. Use this only for trusted content.


pushEscapingFunction

void pushEscapingFunction(String escaperName)
Push a new escaping function onto the context. All calls to writeEscape() will use this new function. When done with this function, call popEscapingFunction() to return to the previous escaping function. If the escaping function is not found, an exception will be thrown. To use no escaping function pass null as the escaperName.

See Also:
popEscapingFunction()

popEscapingFunction

void popEscapingFunction()
See Also:
pushEscapingFunction(String)

pushExecutionContext

void pushExecutionContext(Template template)
Push a new template onto the current execution context. This is to generate stack traces when things go wrong deep in templates, to allow users to figure out how they got there.

See Also:
popExecutionContext()

popExecutionContext

void popExecutionContext()
See Also:
pushExecutionContext(Template)

setCurrentPosition

void setCurrentPosition(int line,
                        int column)
Sets the current position in the template. Used to help generate error messages.


registerMacro

void registerMacro(String name,
                   Macro macro)
Register a macro in the current rendering context. This macro will be available to all other templates, regardless of implementation.


findMacro

Macro findMacro(String name)
                throws JSilverInterpreterException
Lookup a macro that's already been registered. Throws JSilverInterpreterException if macro not found.

Throws:
JSilverInterpreterException

getDataContext

DataContext getDataContext()
Return the DataContext object associated with this RenderingContext.


getResourceLoader

ResourceLoader getResourceLoader()
Returns the ResourceLoader object to use to fetch files needed to render the current template.


getAutoEscapeOptions

AutoEscapeOptions getAutoEscapeOptions()
Returns the configured AutoEscapeOptions to be used while rendering the current template.


pushAutoEscapeMode

void pushAutoEscapeMode(EscapeMode mode)
Push a new auto escaping mode onto the context. Any template loads via include() or evaluateVariable() will use this auto escaping mode when loading the template.

See Also:
popAutoEscapeMode()

popAutoEscapeMode

void popAutoEscapeMode()
See Also:
pushAutoEscapeMode(com.google.clearsilver.jsilver.autoescape.EscapeMode)

getAutoEscapeMode

EscapeMode getAutoEscapeMode()
Read the currently set auto escape mode.

Returns:
EscapeMode

isRuntimeAutoEscaping

boolean isRuntimeAutoEscaping()
Indicates whether runtime auto escaping is in progress.

Returns:
true if runtime auto escaping is enabled.
See Also:
isRuntimeAutoEscaping()

startRuntimeAutoEscaping

void startRuntimeAutoEscaping()
Start an auto escaping context to parse and auto escape template contents as they are being rendered.

See Also:
stopRuntimeAutoEscaping()

stopRuntimeAutoEscaping

void stopRuntimeAutoEscaping()
Stop runtime auto escaping.

See Also:
startRuntimeAutoEscaping()

pushIncludeStackEntry

boolean pushIncludeStackEntry(String templateName)
Adds an entry with a name of the template to the stack keeping all names of already included templates. The name is added only if it is not already on the stack.

Parameters:
templateName - name of the template to be added to the stack. If null a NullPointerException will be thrown.
Returns:
true if the templateName was added.

popIncludeStackEntry

boolean popIncludeStackEntry(String templateName)
Removes an entry with a name of the template from the stack.

Parameters:
templateName -
Returns:
true if the templateName was on the stack.

getIncludedTemplateNames

Iterable<String> getIncludedTemplateNames()
Returns the ordered, mutable stack of names of included templates.



Copyright © 2010-2012 Google. All Rights Reserved.