geirm 01/04/22 11:14:17
Modified: src/java/org/apache/velocity/runtime/directive Include.java
VMProxyArg.java VelocimacroProxy.java
Log:
Support for per-template encoding.
Include.java : simple change - accesses the RM with the encoding. This may
be a problem down the line. Will post on -dev list. But for now, we should
let the Turbiners start working with it, and see what we learn.
VMProxyArg : sm change to support new Runtime.parse() interface
VelocimacroProxy.java : ibid
Revision Changes Path
1.18 +8 -3
jakarta-velocity/src/java/org/apache/velocity/runtime/directive/Include.java
Index: Include.java
===================================================================
RCS file:
/home/cvs/jakarta-velocity/src/java/org/apache/velocity/runtime/directive/Include.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- Include.java 2001/03/20 01:11:23 1.17
+++ Include.java 2001/04/22 18:14:15 1.18
@@ -98,7 +98,7 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Geir Magnusson Jr.</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
- * @version $Id: Include.java,v 1.17 2001/03/20 01:11:23 jon Exp $
+ * @version $Id: Include.java,v 1.18 2001/04/22 18:14:15 geirm Exp $
*/
public class Include extends Directive
{
@@ -196,10 +196,15 @@
arg = value.toString();
Resource resource = null;
-
+
+ Resource current = context.getCurrentResource();
+
try
{
- resource = Runtime.getContent(arg);
+ /*
+ * get the resource, and assume that we use the encoding of the
current template
+ */
+ resource = Runtime.getContent(arg, current.getEncoding());
}
catch (Exception e)
{
1.7 +8 -3
jakarta-velocity/src/java/org/apache/velocity/runtime/directive/VMProxyArg.java
Index: VMProxyArg.java
===================================================================
RCS file:
/home/cvs/jakarta-velocity/src/java/org/apache/velocity/runtime/directive/VMProxyArg.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- VMProxyArg.java 2001/03/21 23:21:26 1.6
+++ VMProxyArg.java 2001/04/22 18:14:15 1.7
@@ -56,6 +56,8 @@
import java.io.ByteArrayInputStream;
import java.io.StringWriter;
+import java.io.StringReader;
+import java.io.BufferedReader;
import org.apache.velocity.context.Context;
import org.apache.velocity.context.InternalContextAdapter;
@@ -111,7 +113,7 @@
* into a local context.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Geir Magnusson Jr.</a>
- * @version $Id: VMProxyArg.java,v 1.6 2001/03/21 23:21:26 geirm Exp $
+ * @version $Id: VMProxyArg.java,v 1.7 2001/04/22 18:14:15 geirm Exp $
*/
public class VMProxyArg
{
@@ -430,8 +432,11 @@
String buff ="#include(" + callerReference + " ) ";
- ByteArrayInputStream inStream = new ByteArrayInputStream(
buff.getBytes() );
- nodeTree = Runtime.parse( inStream, "VMProxyArg:" +
callerReference );
+ //ByteArrayInputStream inStream = new ByteArrayInputStream(
buff.getBytes() );
+
+ BufferedReader br = new BufferedReader( new StringReader( buff
) );
+
+ nodeTree = Runtime.parse( br, "VMProxyArg:" + callerReference );
/*
* now, our tree really is the first DirectiveArg(), and only
one
1.21 +7 -4
jakarta-velocity/src/java/org/apache/velocity/runtime/directive/VelocimacroProxy.java
Index: VelocimacroProxy.java
===================================================================
RCS file:
/home/cvs/jakarta-velocity/src/java/org/apache/velocity/runtime/directive/VelocimacroProxy.java,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- VelocimacroProxy.java 2001/03/20 01:11:28 1.20
+++ VelocimacroProxy.java 2001/04/22 18:14:15 1.21
@@ -57,6 +57,9 @@
import java.io.Writer;
import java.io.IOException;
import java.io.ByteArrayInputStream;
+import java.io.BufferedReader;
+import java.io.StringReader;
+
import java.util.StringTokenizer;
import java.util.HashMap;
import java.util.Set;
@@ -79,7 +82,7 @@
* a proxy Directive-derived object to fit with the current directive system
*
* @author <a href="mailto:[EMAIL PROTECTED]">Geir Magnusson Jr.</a>
- * @version $Id: VelocimacroProxy.java,v 1.20 2001/03/20 01:11:28 jon Exp $
+ * @version $Id: VelocimacroProxy.java,v 1.21 2001/04/22 18:14:15 geirm Exp $
*/
public class VelocimacroProxy extends Directive
{
@@ -271,9 +274,9 @@
// System.out.println("VMP.parseTree() : " + macroName );
try
- {
- ByteArrayInputStream inStream = new ByteArrayInputStream(
macroBody.getBytes() );
- nodeTree = Runtime.parse( inStream, "VM:" + macroName );
+ {
+ BufferedReader br = new BufferedReader( new StringReader( macroBody ) );
+ nodeTree = Runtime.parse( br, "VM:" + macroName );
}
catch ( Exception e )
{