stephenjbell

dotCMS - Velocity-only way to strip out page whitespace

Jul 18th, 2011
268
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. ## dotCMS - Strip whitespace out of current page with only velocity
  2.  
  3. #if($request.getParameter("withwhitespace")!="true")
  4.  
  5. ## Load the alternate version of this page into memory
  6. #set($pageurl = "http://${SERVER_NAME}${VTLSERVLET_URI}?withwhitespace=true&${request.getQueryString()}")
  7. #set($pagesource = $import.read("${pageurl}"))
  8. ## Strip out all special characters and change to one-space
  9. #set($pagesource = $pagesource.replaceAll("[\s]"," "))
  10. #set($pagesource = $pagesource.replaceAll("[ ]{1,999}"," "))
  11. ## Put source back into the page
  12. $pagesource
  13.  
  14. #else
  15.  
  16. YOUR REGULAR PAGE
  17.  
  18.  
  19.  
  20.  
  21. CODE
  22.  
  23. <p><strong>Lots of white space here</strong></p>
  24.  
  25. <p>This page is kind of a mess</p>
  26.  
  27. $request.getParameter("dolphin")
  28. <ul>
  29. #foreach($blogEntry in $dotcontent.pull("+structureName:Blogentry ",10,"modDate desc"))
  30.  
  31. <li>$blogEntry.title</li>
  32.  
  33.  
  34. #end
  35. </ul>
  36.  
  37.  
  38.  
  39. #end
Advertisement
Add Comment
Please, Sign In to add comment