compress html templates when read from disk

2007-03-09 Thread yoursoft

Dear Developers,

I would like to write a plugin to velocity.
This plugin will compress html templates when reading from disk 
(remove white-spaces,  comments etc.), not when Velocity is write to 
output, because my cache modified check time is one hour. :-)


Can you suggest any entry point where I made it? (In 
ContentResource.java at setData(sw.toString())???)


Best Regards,
   Ferenc Lutischan

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



[Velocity Wiki] Update of VelocityWhitespaceGobbleSetindentDirective by MichaelGiroux

2007-03-09 Thread Apache Wiki
Dear Wiki user,

You have subscribed to a wiki page or wiki category on Velocity Wiki for 
change notification.

The following page has been changed by MichaelGiroux:
http://wiki.apache.org/jakarta-velocity/VelocityWhitespaceGobbleSetindentDirective

The comment on the change is:
Revise specification of #setindent based on mailing list suggestion

--
+ {{{
+ March 9, 2007 - revised description of proposed #setindent directive.
+ Based on comments in mailing list, the directive would specify an amount of 
indentation.
+ }}}
  For the most part, I want my templates to be readable and I use indenting to 
accomplish that.  The indenting of the template has nothing to do with the 
desired output.  For example, a simple template to generate a Java class might 
look like this:
  {{{ 
  import com.myco.MyClass;
@@ -33, +37 @@

  {{{ 
  import com.myco.MyClass;
  public Class AnotherClass {
+ #set ($indent = 4)
- #setindent   ## a new setindent directive
+ #setindent($indent)   ## a new setindent directive
- #foreach ($t in $types)
+ #foreach ($t in $types)
- #if ($t.name.contains(_)
+ #if ($t.name.contains(_)
- Integer $t.name = 0;
+ Integer $t.name = 0;
- #if ($t.type == static)
+ #if ($t.type == static)
- // ignore static type $t.name
+ // ignore static type $t.name
+ #end
+ void set${t.name}(Integer v) {
+ #set ($indent = $indent + 4)
+ #setindent($indent)
+ // some code within the method block
+ #set ($indent = $indent - 4)
+ #setindent($indent)
+ }
  #end
  #end
- #end
  }
  }}} 
  
- In this example, a #setindent directive specifies the starting location for 
all subsequent lines.  Velocity would use the whitespace before the #setindent 
directive as the amount to indent any subsequent text that is emitted.
+ In this example, a #setindent directive specifies the amount of whitespace to 
inject at the start of each line of generated text and the template is managing 
a variable ($indent) to keep track of the indentation amount. This strategy 
assumes that all leading whitespace would be ignored, and indentation would be 
controlled exclusively by the #setindent() directives. 
  
- This strategy assumes that all leading whitespace would be ignored, and 
indentation would be controlled exclusively by the #setIndent directives. 
-  
+ This approach requires the template to manage an indentation variable 
($indent) and execute #setindent directives.  ''The template is pretty messy if 
there is not much text being generated.''  It would be nice if #setindent 
managed an internal variable and allowed the template to adjust the variable 
using absolute, increment and decrement values:
+ {{{
+ #setindent(4)  ## set indentation at 4 spaces
+ #setindent(+4) ## increment indentation by 4 spaces
+ #setindent(-4) ## decrement indentation by 4 spaces
+ }}}
+ 
+ This would result in a template like this:
+ {{{ 
+ import com.myco.MyClass;
+ public Class AnotherClass {
+ #setindent(4)   ## set indentation at 4 spaces
+ #foreach ($t in $types)
+ #if ($t.name.contains(_)
+ Integer $t.name = 0;
+ #if ($t.type == static)
+ // ignore static type $t.name
+ #end
+ void set${t.name}(Integer v) {
+ #setindent(+4)   ## add 4 spaces to current indentation
+ // some code within the method block
+ #setindent(-4)   ## remove 4 spaces from current indentation
+ }
+ #end
+ #end
+ }
+ }}} 
+ 
+ 
  I realize that whitespace processing is much more complicated that 
indentation processing alone. This proposal only addresses how velocity could 
be enhanced to control indentation of generated text.  Other approaches can be 
reviewed at VelocityWhitespaceGobbling.
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



[jira] Created: (VELOCITY-527) Name of template truncated in error messages

2007-03-09 Thread Michael Giroux (JIRA)
Name of template truncated in error messages


 Key: VELOCITY-527
 URL: https://issues.apache.org/jira/browse/VELOCITY-527
 Project: Velocity
  Issue Type: Bug
Affects Versions: 1.5
 Environment: Windows XP Pro SP2, JDK 1.5
Reporter: Michael Giroux



Following was posted to mailing list:

On 3/9/07, Will Glass-Husain [EMAIL PROTECTED] wrote:
 Ouch.  Always hate that first bug report after a new release!
 
 Would you mind please creating a JIRA issue at:
 http://issues.apache.org/jira
 
 On 3/9/07, Michael Giroux [EMAIL PROTECTED] wrote:
  I just upgraded to Velocity 1.5.  A key feature for me is the new
  functionality to include filename, line and column in error messages.
  When I was testing this feature with a faulty template, I discovered
  that the filename is being truncated. In the error message below, the
  actual file name should be business-service-interface.vm  It appears
  the parser truncated at the first -.
 
 
  java.lang.Exception: Encountered #else at line 51, column 33 of business
  Was expecting one of: ...
 
 
  Michael:
 
  -
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 
 
 --
 Forio Business Simulations
 
 Will Glass-Husain
 [EMAIL PROTECTED]
 www.forio.com
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



[jira] Commented: (VELOCITY-527) Name of template truncated in error messages

2007-03-09 Thread Michael Giroux (JIRA)

[ 
https://issues.apache.org/jira/browse/VELOCITY-527?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12479722
 ] 

Michael Giroux commented on VELOCITY-527:
-

I modified my code to include the original ParseErrorException as cause.  The 
actual exception is shown here.

In this case, the actual file name is 'session-facade-object.vm' so for 
purposes of this JIRA, we still have an issue. 

In addition, the column number reported as 17 is not exactly correct.  The #set 
line has two leading TAB characters, so I'm not sure if this should be column 2 
or 8, but certainly not 17.  Given whitespace issues, and use of TAB 
characters, it might not be possible to get column correct in any circumstance. 
 

Caused by: org.apache.velocity.exception.ParseErrorException: Encountered 
#set at line 273, column 17 of business
Was expecting one of:
[ ...
{ ...
STRING_LITERAL ...
true ...
false ...
INTEGER_LITERAL ...
FLOATING_POINT_LITERAL ...
IDENTIFIER ...
{ ...

at 
org.apache.velocity.app.VelocityEngine.evaluate(VelocityEngine.java:311)
at 
com.bull.eclipse.businesslayer.core.FileProducer.generate(FileProducer.java:649)
... 51 more

 Name of template truncated in error messages
 

 Key: VELOCITY-527
 URL: https://issues.apache.org/jira/browse/VELOCITY-527
 Project: Velocity
  Issue Type: Bug
Affects Versions: 1.5
 Environment: Windows XP Pro SP2, JDK 1.5
Reporter: Michael Giroux

 Following was posted to mailing list:
 On 3/9/07, Will Glass-Husain [EMAIL PROTECTED] wrote:
  Ouch.  Always hate that first bug report after a new release!
  
  Would you mind please creating a JIRA issue at:
  http://issues.apache.org/jira
  
  On 3/9/07, Michael Giroux [EMAIL PROTECTED] wrote:
   I just upgraded to Velocity 1.5.  A key feature for me is the new
   functionality to include filename, line and column in error messages.
   When I was testing this feature with a faulty template, I discovered
   that the filename is being truncated. In the error message below, the
   actual file name should be business-service-interface.vm  It appears
   the parser truncated at the first -.
  
  
   java.lang.Exception: Encountered #else at line 51, column 33 of business
   Was expecting one of: ...
  
  
   Michael:
  
   -
   To unsubscribe, e-mail: [EMAIL PROTECTED]
   For additional commands, e-mail: [EMAIL PROTECTED]
  
  
  
  
  --
  Forio Business Simulations
  
  Will Glass-Husain
  [EMAIL PROTECTED]
  www.forio.com
  
  -
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
  
  

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



[jira] Commented: (VELOCITY-527) Name of template truncated in error messages

2007-03-09 Thread Nathan Bubna (JIRA)

[ 
https://issues.apache.org/jira/browse/VELOCITY-527?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12479726
 ] 

Nathan Bubna commented on VELOCITY-527:
---

If you are using VelocityEngine.evaluate(...), then you should look at 
FileProducer.java line 649 to start to trace the source of the wrong file name. 
 the evaluate() methods have nothing to do with Files.  they only take Strings, 
InputStreams or Readers.  I believe the logTag parameter is what is being 
treated as the file name.

This may also have something to do with the column and line numbers being off...

 Name of template truncated in error messages
 

 Key: VELOCITY-527
 URL: https://issues.apache.org/jira/browse/VELOCITY-527
 Project: Velocity
  Issue Type: Bug
Affects Versions: 1.5
 Environment: Windows XP Pro SP2, JDK 1.5
Reporter: Michael Giroux

 Following was posted to mailing list:
 On 3/9/07, Will Glass-Husain [EMAIL PROTECTED] wrote:
  Ouch.  Always hate that first bug report after a new release!
  
  Would you mind please creating a JIRA issue at:
  http://issues.apache.org/jira
  
  On 3/9/07, Michael Giroux [EMAIL PROTECTED] wrote:
   I just upgraded to Velocity 1.5.  A key feature for me is the new
   functionality to include filename, line and column in error messages.
   When I was testing this feature with a faulty template, I discovered
   that the filename is being truncated. In the error message below, the
   actual file name should be business-service-interface.vm  It appears
   the parser truncated at the first -.
  
  
   java.lang.Exception: Encountered #else at line 51, column 33 of business
   Was expecting one of: ...
  
  
   Michael:
  
   -
   To unsubscribe, e-mail: [EMAIL PROTECTED]
   For additional commands, e-mail: [EMAIL PROTECTED]
  
  
  
  
  --
  Forio Business Simulations
  
  Will Glass-Husain
  [EMAIL PROTECTED]
  www.forio.com
  
  -
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
  
  

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



[jira] Commented: (VELOCITY-527) Name of template truncated in error messages

2007-03-09 Thread Nathan Bubna (JIRA)

[ 
https://issues.apache.org/jira/browse/VELOCITY-527?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12479733
 ] 

Nathan Bubna commented on VELOCITY-527:
---

cool.   find out anything more about the line  column numbers?  i'm not really 
familiar with the parser code, but it seems to me that those numbers ought to 
still work when parsing from a String, InputStream, or Reader.  can you tell if 
there are any alterations to the template content between the file you're 
looking at in your system and the String/InputStream/Reader that is passed to 
evaluate()?

 Name of template truncated in error messages
 

 Key: VELOCITY-527
 URL: https://issues.apache.org/jira/browse/VELOCITY-527
 Project: Velocity
  Issue Type: Bug
Affects Versions: 1.5
 Environment: Windows XP Pro SP2, JDK 1.5
Reporter: Michael Giroux

 Following was posted to mailing list:
 On 3/9/07, Will Glass-Husain [EMAIL PROTECTED] wrote:
  Ouch.  Always hate that first bug report after a new release!
  
  Would you mind please creating a JIRA issue at:
  http://issues.apache.org/jira
  
  On 3/9/07, Michael Giroux [EMAIL PROTECTED] wrote:
   I just upgraded to Velocity 1.5.  A key feature for me is the new
   functionality to include filename, line and column in error messages.
   When I was testing this feature with a faulty template, I discovered
   that the filename is being truncated. In the error message below, the
   actual file name should be business-service-interface.vm  It appears
   the parser truncated at the first -.
  
  
   java.lang.Exception: Encountered #else at line 51, column 33 of business
   Was expecting one of: ...
  
  
   Michael:
  
   -
   To unsubscribe, e-mail: [EMAIL PROTECTED]
   For additional commands, e-mail: [EMAIL PROTECTED]
  
  
  
  
  --
  Forio Business Simulations
  
  Will Glass-Husain
  [EMAIL PROTECTED]
  www.forio.com
  
  -
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
  
  

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



[jira] Commented: (VELOCITY-527) Name of template truncated in error messages

2007-03-09 Thread Will Glass-Husain (JIRA)

[ 
https://issues.apache.org/jira/browse/VELOCITY-527?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12479778
 ] 

Will Glass-Husain commented on VELOCITY-527:


You might consider using the FileResourceLoader (or one of the other resource 
loaders) instead of Velocity.evaluate().  There's a huge performance benefit 
due to the use of caching.  (assuming you are repeatedly evaluating the files).


 Name of template truncated in error messages
 

 Key: VELOCITY-527
 URL: https://issues.apache.org/jira/browse/VELOCITY-527
 Project: Velocity
  Issue Type: Bug
Affects Versions: 1.5
 Environment: Windows XP Pro SP2, JDK 1.5
Reporter: Michael Giroux

 Following was posted to mailing list:
 On 3/9/07, Will Glass-Husain [EMAIL PROTECTED] wrote:
  Ouch.  Always hate that first bug report after a new release!
  
  Would you mind please creating a JIRA issue at:
  http://issues.apache.org/jira
  
  On 3/9/07, Michael Giroux [EMAIL PROTECTED] wrote:
   I just upgraded to Velocity 1.5.  A key feature for me is the new
   functionality to include filename, line and column in error messages.
   When I was testing this feature with a faulty template, I discovered
   that the filename is being truncated. In the error message below, the
   actual file name should be business-service-interface.vm  It appears
   the parser truncated at the first -.
  
  
   java.lang.Exception: Encountered #else at line 51, column 33 of business
   Was expecting one of: ...
  
  
   Michael:
  
   -
   To unsubscribe, e-mail: [EMAIL PROTECTED]
   For additional commands, e-mail: [EMAIL PROTECTED]
  
  
  
  
  --
  Forio Business Simulations
  
  Will Glass-Husain
  [EMAIL PROTECTED]
  www.forio.com
  
  -
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
  
  

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]