You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by Robert Koberg <ro...@koberg.com> on 2005/03/31 00:18:33 UTC

[whitespace] comment stripping utility?

Hi,

(this is a low priority)

Will Glass-Husain noted yesterday that you can put your velocity code in 
  (X)HTML comments. This works really well for me because I put the code 
in XML source files and transform (pre-generate) them with XSL and use 
the xsl:strip-space="*" directive. So a source file looks like:

<div>

   <!--

   ## some code

   -->

</div>

An XSL (or perhaps DVSL - does it have strip-space?) pregenerated page 
looks like like:

<div><!--

   ## some code

   --></div>

and of course the XHTML looks like:

<div><!--



   --></div>

I was wondering if there exists a property/setting in Velocity that can 
be set so that (X)HTML comments are stripped? If not, would this be 
something to possibly add to the core parser? I looked at the code and 
it is a bit above my head. Is this a practical thing to do?

This is not a huge deal but the pages sent from the server could be a 
bit lighter if it were so. Does this cause an itch among any developers? 
If it does not cause an itch and is practical to do with the parser, I 
could (eventually) try and do this myself.

thanks,
-Rob

---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-dev-help@jakarta.apache.org


Re: [whitespace] comment stripping utility?

Posted by Robert Koberg <ro...@koberg.com>.
Will Glass-Husain wrote:
> Well, the equivalent Velocity block comments are #* commented text *#.
> 
> Maybe you could apply a regexp and transform <!-- into #* and --> into *#?

Good morning folks,

I am on my first cup of coffee, so I might be missing something. But 
wouldn't I have to apply the regexp before the velocity parse for 
velocity to strip the comments. But if I do that then my code would be 
stripped too.

-Rob


> 
> WILL


---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-dev-help@jakarta.apache.org


Re: [whitespace] comment stripping utility?

Posted by Will Glass-Husain <wg...@forio.com>.
Well, the equivalent Velocity block comments are #* commented text *#.

Maybe you could apply a regexp and transform <!-- into #* and --> into *#?

WILL

----- Original Message ----- 
From: "Robert Koberg" <ro...@koberg.com>
To: "Velocity Developers List" <ve...@jakarta.apache.org>
Sent: Wednesday, March 30, 2005 3:13 PM
Subject: Re: [whitespace] comment stripping utility?


> Shinobu Kawai wrote:
>
>>>If not, would this be
>>>something to possibly add to the core parser? I looked at the code and
>>>it is a bit above my head. Is this a practical thing to do?
>>
>>
>> Since Velocity is a generic template engine, IMHO, this kind of
>> function (aimed towards a specific output format) would not belong to
>> the core.
>
> makes sense. Perhaps it could be more generic to get it into the core? 
> Like:
>
> result.comment.strip=true
> result.comment.multiline.start=<!--
> result.comment.multiline.end=-->
> etc...
>
> If this is still too much for the core, do you have suggestions on where 
> it should go? I realize I can make a Filter, but wanted to avoid another 
> parse.
>
>>
>>
>>>This is not a huge deal but the pages sent from the server could be a
>>>bit lighter if it were so. Does this cause an itch among any developers?
>>>If it does not cause an itch and is practical to do with the parser, I
>>>could (eventually) try and do this myself.
>>
>>
>> I'm not sure, but you might be able to make an Anakia/DVSL script to
>> ignore all the comments.  (They're just processing DOMs.)
>
> I want to avoid building a DOM at runtime, even an internal, optimized one 
> if that is the case. In other words, I would just use XSL instead of 
> Velocity if building a DOM for each /request/ was something I wanted to 
> do.
>
> Thanks for your feedback,
> -Rob
>
>>
>> Best regards,
>> -- Shinobu
>>
>> --
>> Shinobu Kawai <sh...@gmail.com>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: velocity-dev-help@jakarta.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-dev-help@jakarta.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-dev-help@jakarta.apache.org


Re: [whitespace] comment stripping utility?

Posted by Robert Koberg <ro...@koberg.com>.
Shinobu Kawai wrote:

>>If not, would this be
>>something to possibly add to the core parser? I looked at the code and
>>it is a bit above my head. Is this a practical thing to do?
> 
> 
> Since Velocity is a generic template engine, IMHO, this kind of
> function (aimed towards a specific output format) would not belong to
> the core.

makes sense. Perhaps it could be more generic to get it into the core? Like:

result.comment.strip=true
result.comment.multiline.start=<!--
result.comment.multiline.end=-->
etc...

If this is still too much for the core, do you have suggestions on where 
it should go? I realize I can make a Filter, but wanted to avoid another 
parse.

> 
> 
>>This is not a huge deal but the pages sent from the server could be a
>>bit lighter if it were so. Does this cause an itch among any developers?
>>If it does not cause an itch and is practical to do with the parser, I
>>could (eventually) try and do this myself.
> 
> 
> I'm not sure, but you might be able to make an Anakia/DVSL script to
> ignore all the comments.  (They're just processing DOMs.)

I want to avoid building a DOM at runtime, even an internal, optimized 
one if that is the case. In other words, I would just use XSL instead of 
Velocity if building a DOM for each /request/ was something I wanted to do.

Thanks for your feedback,
-Rob

> 
> Best regards,
> -- Shinobu
> 
> --
> Shinobu Kawai <sh...@gmail.com>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-dev-help@jakarta.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-dev-help@jakarta.apache.org


Re: [whitespace] comment stripping utility?

Posted by Shinobu Kawai <sh...@gmail.com>.
Hi Robert,

> I was wondering if there exists a property/setting in Velocity that can
> be set so that (X)HTML comments are stripped?

There are none.

> If not, would this be
> something to possibly add to the core parser? I looked at the code and
> it is a bit above my head. Is this a practical thing to do?

Since Velocity is a generic template engine, IMHO, this kind of
function (aimed towards a specific output format) would not belong to
the core.

> This is not a huge deal but the pages sent from the server could be a
> bit lighter if it were so. Does this cause an itch among any developers?
> If it does not cause an itch and is practical to do with the parser, I
> could (eventually) try and do this myself.

I'm not sure, but you might be able to make an Anakia/DVSL script to
ignore all the comments.  (They're just processing DOMs.)

Best regards,
-- Shinobu

--
Shinobu Kawai <sh...@gmail.com>

---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-dev-help@jakarta.apache.org