/scalate-core/src/test/scala/org/fusesource/scalate/ssp/WhitespaceTest.scala

http://github.com/scalate/scalate · Scala · 89 lines · 63 code · 9 blank · 17 comment · 0 complexity · 115178c1ae33c9a4f40442c9e2d75e68 MD5 · raw file

  1. /**
  2. * Copyright (C) 2009-2011 the original author or authors.
  3. * See the notice.md file distributed with this work for additional
  4. * information regarding copyright ownership.
  5. *
  6. * Licensed under the Apache License, Version 2.0 (the "License");
  7. * you may not use this file except in compliance with the License.
  8. * You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. package org.fusesource.scalate
  19. package ssp
  20. class WhitespaceTest extends TemplateTestSupport {
  21. showOutput = true
  22. test("regular ssp directive") {
  23. assertSspOutput("""
  24. person: James
  25. person: Hiram
  26. """, """
  27. <% val people = List("James", "Hiram") %>
  28. <% for (p <- people) { %>
  29. person: ${p}
  30. <% } %>
  31. """)
  32. }
  33. test("velocity style ssp directive") {
  34. assertSspOutput("""
  35. person: James
  36. person: Hiram
  37. """, """
  38. <% val people = List("James", "Hiram") %>
  39. #for(p <- people)
  40. person: ${p}
  41. #end
  42. """)
  43. }
  44. test("ssp ${...} expression whitespace") {
  45. assertSspOutput("""
  46. Copyright 2010 MyCompany
  47. """, """
  48. <% val year = "2010" %>
  49. Copyright ${year} MyCompany
  50. """)
  51. }
  52. test("ssp <%=...%> expression whitespace") {
  53. assertSspOutput("""
  54. Copyright 2010 MyCompany
  55. """, """
  56. <% val year = "2010" %>
  57. Copyright <%=year%> MyCompany
  58. """)
  59. }
  60. test("ssp <%=...%> expression whitespace 2") {
  61. assertSspOutput("""
  62. <tr class="featured">
  63. """, """
  64. <tr<% if(true) { %> class="featured"<% } %>>
  65. """)
  66. }
  67. test("ssp <%=...%> expression whitespace 3") {
  68. assertSspOutput("""
  69. Hello World!""", """
  70. Hello <% if(true) { %>World!<% } %>
  71. """)
  72. }
  73. test("ssp <%=...%> expression whitespace 4") {
  74. assertSspOutput("""
  75. Hello World!
  76. """, """
  77. Hello <% if(true) { %>World!<% } +%>
  78. """)
  79. }
  80. }