Small fix to solve the $# (and variations) problem.
PR:
Obtained from:
Submitted by:
Reviewed by:
git-svn-id: https://svn.apache.org/repos/asf/jakarta/velocity/trunk@74537 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/src/java/org/apache/velocity/runtime/parser/node/ASTText.java b/src/java/org/apache/velocity/runtime/parser/node/ASTText.java
index 132da2c..9179f65 100644
--- a/src/java/org/apache/velocity/runtime/parser/node/ASTText.java
+++ b/src/java/org/apache/velocity/runtime/parser/node/ASTText.java
@@ -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;
+ Token t = getFirstToken();
+
+ text = t.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;
-
- if (NodeUtils.specialText(getFirstToken()).startsWith("$"))
- text = "$" + text;
- else if ( NodeUtils.specialText(getFirstToken()).startsWith("#") )
- text = "#" + text;
-
+ text = NodeUtils.specialText( t ) + t.image;
+
return data;
}
diff --git a/src/java/org/apache/velocity/runtime/parser/node/NodeUtils.java b/src/java/org/apache/velocity/runtime/parser/node/NodeUtils.java
index fab554c..23a8881 100644
--- a/src/java/org/apache/velocity/runtime/parser/node/NodeUtils.java
+++ b/src/java/org/apache/velocity/runtime/parser/node/NodeUtils.java
@@ -63,7 +63,7 @@
*
* @author <a href="mailto:jvanzyl@periapt.com">Jason van Zyl</a>
* @author <a href="mailto:geirm@optonline.net">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;
}