jvanzyl 00/10/03 10:05:46
Modified: src/java/org/apache/velocity/runtime Runtime.java
src/java/org/apache/velocity/runtime/directive Foreach.java
Removed: src/java/org/apache/velocity/runtime/directive Set.java
Log:
- modified for new syntax.
Revision Changes Path
1.4 +4 -2
jakarta-velocity/src/java/org/apache/velocity/runtime/Runtime.java
Index: Runtime.java
===================================================================
RCS file:
/home/cvs/jakarta-velocity/src/java/org/apache/velocity/runtime/Runtime.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Runtime.java 2000/09/30 22:58:13 1.3
+++ Runtime.java 2000/10/03 17:05:41 1.4
@@ -74,7 +74,8 @@
import org.apache.velocity.runtime.configuration.Configuration;
import org.apache.velocity.runtime.directive.Foreach;
-import org.apache.velocity.runtime.directive.Set;
+//import org.apache.velocity.runtime.directive.Set;
+import org.apache.velocity.runtime.directive.Dummy;
public class Runtime
{
@@ -149,7 +150,8 @@
parser = new Parser();
Hashtable directives = new Hashtable();
directives.put("foreach", new Foreach());
- directives.put("set", new Set());
+ //directives.put("set", new Set());
+ directives.put("dummy", new Dummy());
parser.setDirectives(directives);
info("Velocity successfully started.");
1.2 +8 -10
jakarta-velocity/src/java/org/apache/velocity/runtime/directive/Foreach.java
Index: Foreach.java
===================================================================
RCS file:
/home/cvs/jakarta-velocity/src/java/org/apache/velocity/runtime/directive/Foreach.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Foreach.java 2000/09/30 17:04:22 1.1
+++ Foreach.java 2000/10/03 17:05:43 1.2
@@ -31,10 +31,9 @@
// Now we have to iterate over all the child nodes
// for each in the list, we have to change the
// context each time the element changes.
- String elementKey = node.jjtGetChild(0).jjtGetChild(0)
- .jjtGetChild(0).getFirstToken()
- .image.substring(1);
-
+ String elementKey = node.jjtGetChild(0).getFirstToken()
+ .image.substring(1);
+
// if there is an object in the context with
// the same name as the $element save it so
// we can restore it after the #foreach.
@@ -48,9 +47,8 @@
if (context.containsKey(elementKey))
tmp = context.get(elementKey);
- listObject = node.jjtGetChild(0).jjtGetChild(1)
- .jjtGetChild(0).value(context);
-
+ listObject = node.jjtGetChild(2).value(context);
+
/*!
* @desc Need to create a ReferenceException here, for
* example when the listObject is null. This
@@ -65,7 +63,7 @@
for (int i = 0; i < length; i++)
{
context.put(elementKey,((Object[])listObject)[i]);
- node.jjtGetChild(1).render(context, writer);
+ node.jjtGetChild(3).render(context, writer);
}
context.remove(elementKey);
}
@@ -79,7 +77,7 @@
while (i.hasNext())
{
context.put(elementKey,i.next());
- node.jjtGetChild(1).render(context, writer);
+ node.jjtGetChild(3).render(context, writer);
}
context.remove(elementKey);
}
@@ -90,7 +88,7 @@
while (e.hasMoreElements())
{
context.put(elementKey,e.nextElement());
- node.jjtGetChild(1).render(context, writer);
+ node.jjtGetChild(3).render(context, writer);
}
context.remove(elementKey);
}