Date: 2004-10-25T14:10:12
   Editor: TimWhite <[EMAIL PROTECTED]>
   Wiki: Jakarta-Velocity Wiki
   Page: VelocityDebuggingTemplate
   URL: http://wiki.apache.org/jakarta-velocity/VelocityDebuggingTemplate

   no comment

Change Log:

------------------------------------------------------------------------------
@@ -1,6 +1,6 @@
 I've worked a lot with the PHP templating system, Smarty, and I've adapted it's handy 
debugging console for Velocity.
 
- Essentially, if you put the code below into a template called "debug.vm", and you 
#parse it at the end of the template you want to debug (after the </html> tag), it 
will pop up a window with all of the context variables in it, so you can see what is 
being passed to your template.  (Thanks to Dan Chapman for working on this as well).
+ Put the code below into a template called "debug.vm", and #parse it at the end of 
the template you want to debug (after the </html> tag). It will pop up a window with 
all of the context variables in it, so you can see what is being passed to your 
template.  (Thanks to Dan Chapman for working on this as well).
 
  Enjoy!
 
@@ -13,42 +13,36 @@
                #set ($rowLength = 15)
        #end
        #if (($velocityCount % 2) == 0)
-               _velocity_console.document.write("<tr
-bgcolor=#fafafa>");
+               _velocity_console.document.write("<tr bgcolor=#fafafa>");
        #else
-               _velocity_console.document.write("<tr
-bgcolor=#eeeeee>");
+               _velocity_console.document.write("<tr bgcolor=#eeeeee>");
        #end
        _velocity_console.document.write("<td valign=top><tt><font color=maroon>$" + 
"$name" + "</font></tt></td>");
        #if ($rowLength == 1)
-               _velocity_console.document.write("<td><tt><font
-color=green>$value</font></tt></td></tr>");
+               _velocity_console.document.write("<td><tt><font 
color=green>$value</font></tt></td></tr>");
        #else
-               _velocity_console.document.write("<td><tt><font
-color=green><textarea rows=$rowLength cols=57>");
+               _velocity_console.document.write("<td><tt><font color=green><textarea 
rows=$rowLength cols=57>");
                _velocity_console.document.write("$value");
-       
-_velocity_console.document.write("</textarea></font></tt></td></tr>");
+               _velocity_console.document.write("</textarea></font></tt></td></tr>");
        #end
 #end
 
 <script language=javascript>
        _velocity_console = 
window.open("",true,"width=680,height=600,resizable,scrollbars=yes");
-       _velocity_console.document.write("<html><head><title>Velocity
-Debug Console</title></head><body bgcolor=#ffffff>");
+       _velocity_console.document.write("<html><head><title>Velocity Debug 
Console</title></head><body bgcolor=#ffffff>");
        _velocity_console.document.write("<table border=0 width=100%>");
        _velocity_console.document.write("<tr bgcolor=#000000><th colspan='2'><b><font 
color=#FFFFFF>Velocity Debug Console</font></b></td></tr>");
        _velocity_console.document.write("<tr bgcolor=#cccccc><td 
colspan='2'><b>Request Attributes:</b></td></tr>");
        #foreach ($name in $request.getAttributeNames())
-               #printRow($name 
$request.getAttribute($name).toString().replaceAll("\n", "\\n"))
+               #printRow($name 
$request.getAttribute($name).toString().replaceAll("\n", "\\n").replaceAll("\r", ""))
        #end 
        _velocity_console.document.write("<tr bgcolor=#cccccc><td 
colspan='2'><b>Request Parameters:</b></td></tr>");
        #foreach ($name in ${request.getParameterNames()})
-               #printRow($name 
$request.getParameter($name).toString().replaceAll("\n", "\\n"))
+               #printRow($name 
$request.getParameter($name).toString().replaceAll("\n", "\\n").replaceAll("\r", ""))
        #end
        _velocity_console.document.write("<tr bgcolor=#cccccc><td 
colspan='2'><b>Session Attributes:</b></td></tr>");
        #foreach ($name in ${session.getAttributeNames()})
-               #printRow($name 
$session.getAttribute($name).toString().replaceAll("\n", "\\n"))
+               #printRow($name 
$session.getAttribute($name).toString().replaceAll("\n", "\\n").replaceAll("\r", ""))
        #end
        _velocity_console.document.write("</table>");
        _velocity_console.document.write("</body></html>");

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

Reply via email to