Package org.xwiki.velocity
Interface VelocityEngine
-
@Role public interface VelocityEngine
Initialize a Velocity Engine and make Velocity services available.- Version:
- $Id: 1f22301b90c40969fde9031559205ebfa6a704bf $
-
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description voidclearMacroNamespace(String namespace)Deprecated.since 10.5RC1, the macros are now stored in the execution context so this method does not make much sense anymorebooleanevaluate(org.apache.velocity.context.Context context, Writer out, String namespace, Reader source)Renders the input string using the context into the output writer.booleanevaluate(org.apache.velocity.context.Context context, Writer out, String namespace, String source)Renders the input string using the context into the output writer.voidinitialize(Properties properties)Initializes the Velocity engine by setting its configuration both from the component's configuration and from the passed properties.voidstartedUsingMacroNamespace(String namespace)Notify that a rendering action is starting in the given namespace.voidstoppedUsingMacroNamespace(String namespace)Notify that a rendering action in the given namespace just finished.
-
-
-
Method Detail
-
initialize
void initialize(Properties properties) throws XWikiVelocityException
Initializes the Velocity engine by setting its configuration both from the component's configuration and from the passed properties. This method must be called before any other method from this class can be executed.- Parameters:
properties- the properties that will override the static properties defined in the component's configuration- Throws:
XWikiVelocityException- in case of error
-
evaluate
boolean evaluate(org.apache.velocity.context.Context context, Writer out, String namespace, String source) throws XWikiVelocityExceptionRenders the input string using the context into the output writer.- Parameters:
context- the Velocity context to use in rendering the input string, it's recommended to pass aXWikiVelocityContextto have retro compatibility support (like old $velocitycount binding)out- the writer in which to render the outputnamespace- the string to be used as the template name for log messages in case of error. Also used as namespace for the macros. Empty string means global namespace.source- the input string containing the VTL to be rendered- Returns:
- true if successful, false otherwise. If false, see the Velocity runtime log
- Throws:
XWikiVelocityException- in case of error
-
evaluate
boolean evaluate(org.apache.velocity.context.Context context, Writer out, String namespace, Reader source) throws XWikiVelocityExceptionRenders the input string using the context into the output writer.- Parameters:
context- the Velocity context to use in rendering the input stringout- the writer in which to render the outputnamespace- the string to be used as the template name for log messages in case of error. Also used as namespace for the macros. Empty string means global namespace.source- the input containing the VTL to be rendered, as a Reader- Returns:
- false if empty, true otherwise
- Throws:
XWikiVelocityException- in case of error
-
clearMacroNamespace
@Deprecated void clearMacroNamespace(String namespace)
Deprecated.since 10.5RC1, the macros are now stored in the execution context so this method does not make much sense anymoreClear the internal Velocity Macro cache for the passed namespace.- Parameters:
namespace- the namespace for which to remove all cached Velocity macros- Since:
- 2.4M2
-
startedUsingMacroNamespace
void startedUsingMacroNamespace(String namespace)
Notify that a rendering action is starting in the given namespace.- Parameters:
namespace- the namespace being used- Since:
- 2.4RC1
-
stoppedUsingMacroNamespace
void stoppedUsingMacroNamespace(String namespace)
Notify that a rendering action in the given namespace just finished.- Parameters:
namespace- the namespace which was used- Since:
- 2.4RC1
-
-