This is an automated email from the ASF dual-hosted git repository.

cbrisson pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/velocity-engine.git


The following commit(s) were added to refs/heads/master by this push:
     new 22dc54d4 Clarify template reuse in RuntimeInstance javadoc
22dc54d4 is described below

commit 22dc54d4a2b990d57e49d4535b4330ce22c9ba0a
Author: Claude Brisson <[email protected]>
AuthorDate: Sun Sep 1 08:53:16 2024 +0200

    Clarify template reuse in RuntimeInstance javadoc
---
 .../org/apache/velocity/runtime/RuntimeInstance.java   | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git 
a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeInstance.java
 
b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeInstance.java
index 0379e651..ada01e64 100644
--- 
a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeInstance.java
+++ 
b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeInstance.java
@@ -1456,8 +1456,22 @@ public class RuntimeInstance implements 
RuntimeConstants, RuntimeServices
 
 
     /**
-     * Initializes and renders the AST {@link SimpleNode} using the context
-     * into the output writer.
+     * <p>Initializes and renders the AST {@link SimpleNode} using the context
+     * into the output writer.</p>
+     * <p>Note that the <code>nodeTree</code> argument should be a fresh AST 
tree obtained by the
+     * {@link #parse(Reader, Template)} method.</p>
+     * <p>If you wish to reuse AST trees but bypass the resource loading 
mechanism, you should rely on the Template API,
+     * as follow:</p>
+     * <pre><code>
+     *      RuntimeInstance runtimeInstance = new RuntimeInstance();
+     *      Template template = new Template();
+     *      template.setName("my_template");
+     *      template.setRuntimeServices(runtimeInstance);
+     *      SimpleNode astTree = runtimeInstance.parse(new StringReader("Some 
template..."), template);
+     *      template.setData(astTree);
+     *      template.initDocument();
+     * </code></pre>
+     * <p>You will then be able to render several times the template with 
<code>template.render(context, writer)</code>.</p>
      *
      * @param context context to use in rendering input string
      * @param writer  Writer in which to render the output

Reply via email to