[prev in list] [next in list] [prev in thread] [next in thread] 

List:       velocity-dev
Subject:    cvs commit: jakarta-velocity/src/java/org/apache/velocity/runtime/directive Parse.java
From:       geirm () apache ! org
Date:       2001-07-23 2:31:09
[Download RAW message or body]

geirm       01/07/22 19:31:09

  Modified:    src/java/org/apache/velocity/runtime/directive Parse.java
  Log:
  Fix to parallel the #incude() fix, allowing that there may be no current
  resource to mimic the encoding of, so take from default
  
  Revision  Changes    Path
  1.20      +21 -2     jakarta-velocity/src/java/org/apache/velocity/runtime/directive/Parse.java
  
  Index: Parse.java
  ===================================================================
  RCS file: /home/cvs/jakarta-velocity/src/java/org/apache/velocity/runtime/directive/Parse.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- Parse.java	2001/07/03 20:22:06	1.19
  +++ Parse.java	2001/07/23 02:31:09	1.20
  @@ -64,6 +64,7 @@
   import org.apache.velocity.runtime.parser.ParserTreeConstants;
   import org.apache.velocity.runtime.parser.node.Node;
   import org.apache.velocity.runtime.parser.node.SimpleNode;
  +import org.apache.velocity.runtime.resource.Resource;
   import org.apache.velocity.util.StringUtils;
   
   import org.apache.velocity.exception.MethodInvocationException;
  @@ -86,7 +87,7 @@
    * @author <a href="mailto:geirm@optonline.net">Geir Magnusson Jr.</a>
    * @author <a href="mailto:jvanzyl@periapt.com">Jason van Zyl</a>
    * @author <a href="mailto:Christoph.Reck@dlr.de">Christoph Reck</a>
  - * @version $Id: Parse.java,v 1.19 2001/07/03 20:22:06 geirm Exp $
  + * @version $Id: Parse.java,v 1.20 2001/07/23 02:31:09 geirm Exp $
    */
   public class Parse extends Directive
   {
  @@ -164,6 +165,24 @@
               return false;
           }
   
  +       Resource current = context.getCurrentResource();
  +
  +        /*
  +         *  get the resource, and assume that we use the encoding of the current template
  +         *  the 'current resource' can be null if we are processing a stream....
  +         */
  +
  +        String encoding = null;
  +
  +        if ( current != null)
  +        {
  +            encoding = current.getEncoding();
  +        }
  +        else
  +        {
  +            encoding = (String) Runtime.getProperty( Runtime.INPUT_ENCODING);
  +        }
  +
           /*
            *  now use the Runtime resource loader to get the template
            */
  @@ -171,7 +190,7 @@
   
           try 
           {
  -            t = Runtime.getTemplate( arg, context.getCurrentResource().getEncoding() );   
  +            t = Runtime.getTemplate( arg, encoding );   
           }
           catch ( Exception e)
           {
  
  
  

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic