You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by jo...@locus.apache.org on 2000/08/25 08:59:50 UTC
cvs commit: jakarta-velocity/src/java/org/apache/velocity Template.java Test.java
jon 00/08/24 23:59:49
Modified: src/java/org/apache/velocity Template.java Test.java
Log:
Below is a patch which I did to get Velocity to return the parsed
document. I also updated Test.java to reflect these changes. I was
able to move from a WebMacro page to Velocity fairly quickly once I
figured out the NPE that was being throw within the Exception. You can
see the simple finished product at http://www.diarylog.org.
Anyways, here's the patch. Great work!
Josh Lucas <jo...@stonecottage.com>
Revision Changes Path
1.2 +9 -2 jakarta-velocity/src/java/org/apache/velocity/Template.java
Index: Template.java
===================================================================
RCS file: /home/cvs/jakarta-velocity/src/java/org/apache/velocity/Template.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Template.java 2000/08/24 21:42:46 1.1
+++ Template.java 2000/08/25 06:59:49 1.2
@@ -67,6 +67,7 @@
*
* template.setContext(context);
* template.parse();
+ * String output = template.getOutput();
*/
public class Template
{
@@ -76,6 +77,8 @@
protected Parser parser;
/** The context against which the template is parsed */
protected Context context;
+ /** The output of the parsed template */
+ protected String output;
public Template(String template)
{
@@ -92,6 +95,11 @@
this.context = context;
}
+ public String getOutput()
+ {
+ return output;
+ }
+
public void parse()
{
try
@@ -102,11 +110,10 @@
//DumpVisitor visitor = new DumpVisitor();
visitor.setContext(context);
parser.getRoot().jjtAccept(visitor, null);
- System.out.println(visitor.getDocument());
+ this.output = visitor.getDocument();
}
catch(Exception e)
{
- System.out.println("!! " + parser.token.image);
System.out.println(e);
e.printStackTrace();
}
1.2 +1 -0 jakarta-velocity/src/java/org/apache/velocity/Test.java
Index: Test.java
===================================================================
RCS file: /home/cvs/jakarta-velocity/src/java/org/apache/velocity/Test.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Test.java 2000/08/24 21:42:46 1.1
+++ Test.java 2000/08/25 06:59:49 1.2
@@ -75,6 +75,7 @@
template.setContext(context);
template.parse();
+ System.out.println(template.getDocument());
}
public static void main(String[] args)