geirm 01/03/18 17:36:30
Modified: src/java/org/apache/velocity/runtime/parser/node
ASTText.java NodeUtils.java
Log:
Small fix to solve the $# (and variations) problem.
Revision Changes Path
1.6 +6 -14
jakarta-velocity/src/java/org/apache/velocity/runtime/parser/node/ASTText.java
Index: ASTText.java
===================================================================
RCS file:
/home/cvs/jakarta-velocity/src/java/org/apache/velocity/runtime/parser/node/ASTText.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- ASTText.java 2001/01/03 05:27:19 1.5
+++ ASTText.java 2001/03/19 01:36:30 1.6
@@ -60,6 +60,7 @@
import org.apache.velocity.context.InternalContextAdapter;
import org.apache.velocity.runtime.parser.Parser;
+import org.apache.velocity.runtime.parser.Token;
public class ASTText extends SimpleNode
{
@@ -83,21 +84,12 @@
public Object init( InternalContextAdapter context, Object data) throws
Exception
{
- // text = NodeUtils.specialText(getFirstToken()) +
- // getFirstToken().image;
-
- /*
- * there is only one special case we care about now : if the specialToken
leads with a $
- * Everything else seems to be working right now
- */
-
- text = getFirstToken().image;
+ Token t = getFirstToken();
+
+ text = t.image;
- if (NodeUtils.specialText(getFirstToken()).startsWith("$"))
- text = "$" + text;
- else if ( NodeUtils.specialText(getFirstToken()).startsWith("#") )
- text = "#" + text;
-
+ text = NodeUtils.specialText( t ) + t.image;
+
return data;
}
1.10 +16 -2
jakarta-velocity/src/java/org/apache/velocity/runtime/parser/node/NodeUtils.java
Index: NodeUtils.java
===================================================================
RCS file:
/home/cvs/jakarta-velocity/src/java/org/apache/velocity/runtime/parser/node/NodeUtils.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- NodeUtils.java 2001/01/03 05:27:38 1.9
+++ NodeUtils.java 2001/03/19 01:36:30 1.10
@@ -63,7 +63,7 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Geir Magnusson Jr.</a>
- * @version $Id: NodeUtils.java,v 1.9 2001/01/03 05:27:38 geirm Exp $
+ * @version $Id: NodeUtils.java,v 1.10 2001/03/19 01:36:30 geirm Exp $
*/
public class NodeUtils
{
@@ -90,7 +90,21 @@
while (tmp_t != null)
{
- specialText += tmp_t.image;
+ String st = tmp_t.image;
+
+ StringBuffer sb = new StringBuffer("");
+
+ for(int i = 0; i < st.length(); i++)
+ {
+ char c = st.charAt(i);
+
+ if ( c == '#' || c == '$' )
+ sb.append( c );
+ }
+
+ // specialText += tmp_t.image;
+ specialText += sb.toString();
+
tmp_t = tmp_t.next;
}