Please, everyone vote for some type of whitespace gobbling to appear in
Velocity 2.
To vote:
go to http://wiki.apache.org/jakarta-velocity/VelocityWhitespaceGobbling
* click on 'login' (don't worry if you're not registered you can
register after you've clicked 'login')
* register or login
* go back to
http://wiki.apache.org/jakarta-velocity/VelocityWhitespaceGobbling
* click 'edit'
* scroll down to the voting bit and add your name and obfuscated email
address.
This is really important as if the powers that be don't know that lots
of people want (and need) this they may not bother to add it!
Ok, here's a 'real-world' example of how the comments at the end of the
line looks and works, from the header of www.peoplesarchive.com :
original code:
<ul class="navigation">
<li class="first
#if ($sectionName.equals("home"))
selected_list_item
#end
"><a href="/">home</a></li>
<li
#if ($sectionName.equals("browse"))
class="selected_list_item"
#end
><a href="/browse/">browse</a></li>
<li
#if ($sectionName.equals("search"))
class="selected_list_item"
#end
><a href="/search/">search</a></li>
<li
#if ($sectionName.equals("playlists"))
class="selected_list_item"
#end
><a href="/playlists/">playlists</a></li>
#if ($subscription == 0)
<li
#if ($sectionName.equals("login"))
class="selected_list_item"
#end
><a href="/login/">login</a></li>
<li
#if ($sectionName.equals("register"))
class="selected_list_item"
#end
><a href="/register/">register</a></li>
#else
<li
#if ($sectionName.equals("logout"))
class="selected_list_item"
#end
><a href="/login/logout.jsp">logout</a></li>
<li
#if ($sectionName.equals("myarchive"))
class="selected_list_item"
#end
><a href="/myarchive/">my archive</a></li>
#end
<li
#if ($sectionName.equals("about"))
class="selected_list_item"
#end
><a href="/about/">about us</a></li>
<li
#if ($sectionName.equals("contact"))
class="selected_list_item"
#end
><a href="/contact/">contact</a></li>
<li
#if ($sectionName.equals("feedback"))
class="selected_list_item"
#end
><a href="/feedback/">feedback</a></li>
</ul>
code trying to eliminate whitespace
<ul class="navigation">##
<li class="first##
#if ($sectionName.equals("home"))##
selected_list_item ##
#end##
"><a href="/">home</a></li>##
##
<li##
#if ($sectionName.equals("browse"))##
class="selected_list_item"##
#end##
><a href="/browse/">browse</a></li>##
##
<li##
#if ($sectionName.equals("search"))##
class="selected_list_item"##
#end##
><a href="/search/">search</a></li>##
##
<li##
#if ($sectionName.equals("playlists"))##
class="selected_list_item"##
#end##
><a href="/playlists/">playlists</a></li>##
##
#if ($subscription == 0)##
##
<li##
#if ($sectionName.equals("login")) ##
class="selected_list_item"##
#end##
><a href="/login/">login</a></li>##
##
<li##
#if ($sectionName.equals("register"))##
class="selected_list_item"##
#end##
><a href="/register/">register</a></li>##
##
#else##
##
<li##
#if ($sectionName.equals("logout"))##
class="selected_list_item"##
#end##
><a href="/login/logout.jsp">logout</a></li>##
##
<li##
#if ($sectionName.equals("myarchive"))##
class="selected_list_item"##
#end##
><a href="/myarchive/">my archive</a></li>##
##
#end##
##
##
<li##
#if ($sectionName.equals("about"))##
class="selected_list_item"##
#end##
><a href="/about/">about us</a></li>##
##
<li##
#if ($sectionName.equals("contact"))##
class="selected_list_item"##
#end##
><a href="/contact/">contact</a></li>##
##
<li##
#if ($sectionName.equals("feedback"))##
class="selected_list_item"##
#end##
><a href="/feedback/">feedback</a></li>##
##
</ul>
The first version makes the header twice as long as all the whitespace
pads it out, the second is normal but the code is now awful!
Please, everyone vote for some type of whitespace gobbling to appear in
Velocity 2.
To vote:
go to http://wiki.apache.org/jakarta-velocity/VelocityWhitespaceGobbling
* click on 'login' (don't worry if you're not registered you can
register after you've clicked 'login')
* register or login
* go back to
http://wiki.apache.org/jakarta-velocity/VelocityWhitespaceGobbling
* click 'edit'
* scroll down to the voting bit and add your name and obfuscated email
address.
This is really important as if the powers that be don't know that lots
of people want (and need) this they may not bother to add it!
Paul.
Marc Novakowski wrote:
I've been meaning to add my vote to this page, so I finally did it.
+1 for gobbling structured templates.
We use velocity for most of the "backstage" area at Pandora. It's
made development so much easier! However, the final HTML looks quite
messy due to all of the extra whitespace introduced by the velocity
templates.
Marc
On 14-Nov-06, at 8:18 AM, [EMAIL PROTECTED] wrote:
See the Wiki on this issue:
http://wiki.apache.org/jakarta-velocity/VelocityWhitespaceGobbling
Please add your opinion (well thought out) or vote for one of the
presented approaches.
Cheers,
Christoph
Paul Loy wrote:
I would be very interested in a solution to this problem. From a code
layout point of view this would be an important feature. Consider:
<div>
"
#if ($somevar)
$somevar
#else
nothing here
#end
"
</div>
This nicely formatted code makes it easy to see what's going on but
will
make the html render with spaces in it like so (if $somevar is false or
null):
' nothing here '
Now this is a silly example and in this case it would be much easier to
simply do this to eliminate the problem:
<div>
#if ($somevar)
"$somevar"
#else
"nothing here"
#end
</div>
but in more complex examples you'd either have a great amount of
duplicated HTML, which makes it bad to maintain and update, or you'd
have to make unreadable code (everything on one line with no white
spaces).
I converted an old nasty taglibbed jsp into velocity and although I
cleaned up the html (removing 20+ unnecessary nested tables) the
filesize of the velocity version was actually slightly bigger than the
old version because of all the whitespace.
So... I would very much like velocity to perhaps remove whitespace
between a directive (i.e. a # statement) and any other code.
Paul.
Timothy Stone wrote:
List,
We noticed in #parse'ing an .vm file, excess whitespace, or linefeeds,
are appearing in our templates after merge.
For example, where a '+' indicates a line feed or carriage return:
[mystyles.vm]
+
#set( $foo = "Copyright (c)")
+
#set( $bar = "2006" )
+
[myemail.txt]
#parse("mystyles.vm")
+
Dear bloated warthog,
blah
+
blah
+
blah
+
Regards,
Man in Black
+
${foo} ${bar}
[The final output]
+
+
+
+
Dear bloated warthog,
blah
+
blah
+
blah
+
Regards,
Man in Black
+
Copyright (c) 2006
Can these extra lines be managed in some way?
Thanks,
Tim
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
*Paul Loy
Software Developer*
Peoples Archive Ltd.
Middlesex House
34-42 Cleveland Street
London, W1T 4LB
Tel: +44 (0) 20 7323 0323
Fax: +44 (0) 20 7580 1938
[EMAIL PROTECTED]
This email has been scanned by Postini.
For more information please visit http://www.postini.com