PageRenderTime 23ms CodeModel.GetById 16ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/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 */
18package org.fusesource.scalate
19package ssp
20
21class WhitespaceTest extends TemplateTestSupport {
22
23  showOutput = true
24
25  test("regular ssp directive") {
26    assertSspOutput("""
27  person: James
28  person: Hiram
29""", """
30<% val people = List("James", "Hiram") %>
31<% for (p <- people) { %>
32  person: ${p}
33<% } %>
34""")
35  }
36
37  test("velocity style ssp directive") {
38    assertSspOutput("""
39  person: James
40  person: Hiram
41""", """
42<% val people = List("James", "Hiram") %>
43#for(p <- people)
44  person: ${p}
45#end
46""")
47  }
48
49  test("ssp ${...} expression whitespace") {
50    assertSspOutput("""
51  Copyright 2010 MyCompany
52""", """
53<% val year = "2010" %>
54  Copyright ${year} MyCompany
55""")
56  }
57
58  test("ssp <%=...%> expression whitespace") {
59    assertSspOutput("""
60  Copyright 2010 MyCompany
61""", """
62<% val year = "2010" %>
63  Copyright <%=year%> MyCompany
64""")
65  }
66
67  test("ssp <%=...%> expression whitespace 2") {
68    assertSspOutput("""
69  <tr class="featured">
70""", """
71  <tr<% if(true) { %> class="featured"<% } %>>
72""")
73  }
74
75  test("ssp <%=...%> expression whitespace 3") {
76    assertSspOutput("""
77  Hello World!""", """
78  Hello <% if(true) { %>World!<% } %>
79""")
80  }
81
82  test("ssp <%=...%> expression whitespace 4") {
83    assertSspOutput("""
84  Hello World!
85""", """
86  Hello <% if(true) { %>World!<% } +%>
87""")
88  }
89}