trellis 0.0.6 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -237,6 +237,28 @@ module Utils
237
237
  end
238
238
  result
239
239
  end
240
+ end
241
+
242
+ module Markaby
240
243
 
244
+ def self.build(*args, &block)
245
+ Markaby::Builder.new(*args, &block).to_s
246
+ end
247
+
248
+ class Builder
249
+
250
+ def thtml(&block)
251
+ tag!(:html,
252
+ :xmlns => "http://www.w3.org/1999/xhtml",
253
+ "xml:lang" => "en",
254
+ :lang => "en",
255
+ "xmlns:trellis" => "http://trellisframework.org/schema/trellis_1_0_0.xsd", &block)
256
+ end
257
+
258
+ def render_body
259
+ text %[@!{@body}@]
260
+ end
261
+
262
+ end
241
263
  end
242
264
 
@@ -28,7 +28,7 @@ module Trellis
28
28
  module VERSION #:nodoc:
29
29
  MAJOR = 0
30
30
  MINOR = 0
31
- TINY = 6
31
+ TINY = 7
32
32
 
33
33
  STRING = [MAJOR, MINOR, TINY].join('.')
34
34
  end
@@ -1,6 +1,7 @@
1
1
  require File.dirname(__FILE__) + '/spec_helper.rb'
2
2
 
3
3
  require "rack"
4
+ require 'rack/test'
4
5
  require_fixtures 'application_spec_applications'
5
6
 
6
7
  describe Trellis::Application, " when declared" do
@@ -32,88 +33,196 @@ describe Trellis::Application, " when declared" do
32
33
  end
33
34
 
34
35
  describe Trellis::Application, " when requesting the root url with a GET" do
35
- before(:each) do
36
- application = TestApp::MyApp.new
37
- request = Rack::MockRequest.new(application)
38
- @response = request.get("/")
36
+ include Rack::Test::Methods
37
+
38
+ def app
39
+ TestApp::MyApp.new
39
40
  end
40
41
 
41
42
  it "should return an OK HTTP status" do
42
- @response.status.should be(200)
43
+ get "/"
44
+ last_response.status.should be(200)
43
45
  end
44
46
 
45
47
  it "should reply with the home page" do
46
- @response.body.should == "<html><body><h1>Hello World!</h1></body></html>"
48
+ get "/"
49
+ last_response.body.should == %[<?xml version=\"1.0\"?>\n<html>\n <body>\n <h1>Hello World!</h1>\n </body>\n</html>\n]
47
50
  end
48
51
  end
49
52
 
50
53
  describe Trellis::Application, " requesting a route" do
51
- before(:each) do
52
- application = TestApp::MyApp.new
53
- @request = Rack::MockRequest.new(application)
54
+ include Rack::Test::Methods
55
+
56
+ def app
57
+ TestApp::MyApp.new
54
58
  end
55
59
 
56
- it "should return a 404 (not found)" do
57
- response = @request.get("/blowup")
58
- response.status.should be(404)
60
+ it "should return a 404 (not found) for an unmatch request" do
61
+ get "/blowup"
62
+ last_response.status.should be(404)
59
63
  end
60
64
 
61
65
  it "should return the page contents of the first page matching the route" do
62
- response = @request.get("/whoa")
63
- response.body.should == "<html><body>whoa!</body></html>"
66
+ get "/whoa"
67
+ last_response.body.should == "<?xml version=\"1.0\"?>\n<html>\n <body>whoa!</body>\n</html>\n"
64
68
  end
65
69
 
66
70
  it "should support a single named parameter" do
67
- response_brian = @request.get("/hello/brian")
68
- response_anne = @request.get("/hello/anne")
69
- response_brian.body.should == "<html><body><h2>Hello</h2>brian</body></html>"
70
- response_anne.body.should == '<html><body><h2>Hello</h2>anne</body></html>'
71
+ get "/hello/brian"
72
+ last_response.body.should include("<body>\n <h2>Hello</h2>\n \n brian\n </body>")
73
+ get "/hello/anne"
74
+ last_response.body.should include("<body>\n <h2>Hello</h2>\n \n anne\n </body>")
71
75
  end
72
76
 
73
77
  it "should support multiple named parameters" do
74
- response = @request.get('/report/2009/05/31')
75
- response.body.should == "<html><body><h2>Report for</h2>05/31/2009</body></html>"
78
+ get '/report/2009/05/31'
79
+ last_response.body.should include("<body><h2>Report for</h2>05/31/2009</body>")
76
80
  end
77
81
 
78
82
  it "should support optional parameters" do
79
- response_all_params = @request.get('/foobar/hello/world')
80
- response_one_param = @request.get('/foobar/hello')
81
- response_no_param = @request.get('/foobar')
82
- response_all_params.body.should == "<html><body>hello-world</body></html>"
83
- response_one_param.body.should == "<html><body>hello-</body></html>"
84
- response_no_param.body.should == "<html><body>-</body></html>"
83
+ get '/foobar/hello/world'
84
+ last_response.body.should include("<body>hello-world</body>")
85
+ get '/foobar/hello'
86
+ last_response.body.should include("<body>hello-</body>")
87
+ get '/foobar'
88
+ last_response.body.should include("<body>-</body>")
85
89
  end
86
90
 
87
91
  it "should support a wildcard parameters" do
88
- response = @request.get('/splat/goodbye/cruel/world')
89
- response.body.should == '<html><body>goodbye/cruel/world</body></html>'
92
+ get '/splat/goodbye/cruel/world'
93
+ last_response.body.should include("goodbye/cruel/world")
90
94
  end
91
95
 
92
96
  it "should supports mixing multiple splats" do
93
- response = @request.get('/splats/bar/foo/bling/baz/boom')
94
- response.body.should == '<html><body>barblingbaz/boom</body></html>'
97
+ get '/splats/bar/foo/bling/baz/boom'
98
+ last_response.body.should include("barblingbaz/boom")
95
99
 
96
- no_route_response = @request.get('/splats/bar/foo/baz')
97
- no_route_response.status.should be(404)
100
+ get '/splats/bar/foo/baz'
101
+ last_response.status.should be(404)
98
102
  end
99
103
 
100
104
  it "should supports mixing named and wildcard params" do
101
- response = @request.get('/mixed/afoo/bar/baz')
102
- response.body.should == '<html><body>bar/baz-afoo</body></html>'
105
+ get '/mixed/afoo/bar/baz'
106
+ last_response.body.should include("bar/baz-afoo")
103
107
  end
104
108
 
105
109
  it "should merge named params and query string params" do
106
- response_mr_bean = @request.get("/hello/Bean?salutation=Mr.%20")
107
- response_mr_bean.body.should == "<html><body><h2>Hello</h2>Mr. Bean</body></html>"
110
+ get "/hello/Bean?salutation=Mr.%20"
111
+ last_response.body.should include("<h2>Hello</h2>\n Mr. \n Bean")
108
112
  end
109
113
 
110
114
  it "should match a dot ('.') as part of a named param" do
111
- response = @request.get("/foobar/user@example.com/thebar")
112
- response.body.should == "<html><body>user@example.com-thebar</body></html>"
115
+ get "/foobar/user@example.com/thebar"
116
+ last_response.body.should include("user@example.com-thebar")
113
117
  end
114
118
 
115
119
  it "should match a literal dot ('.') outside of named params" do
116
- response = @request.get("/downloads/logo.gif")
117
- response.body.should == "<html><body>logo-gif</body></html>"
120
+ get "/downloads/logo.gif"
121
+ last_response.body.should include("logo-gif")
122
+ end
123
+
124
+ it "should redirect to a custom route when handling an event returning a custom routed page" do
125
+ post "/admin/login/events/submit.login"
126
+ redirect = last_response.headers['Location']
127
+ redirect.should eql('/admin/result')
128
+ get redirect
129
+ last_response.body.should include('<h1>PostRedirectPage</h1>')
130
+ end
131
+
132
+ end
133
+
134
+ describe Trellis::Application do
135
+ include Rack::Test::Methods
136
+
137
+ def app
138
+ TestApp::MyApp.new
139
+ end
140
+
141
+ it "should have access to any persistent fields" do
142
+ get "/application_data_page"
143
+ last_response.body.should == "<?xml version=\"1.0\"?>\n<html>\n <body>\n <p></p>\n </body>\n</html>\n"
144
+ end
145
+
146
+ it "should be able to modify any persistent fields" do
147
+ env = Hash.new
148
+ env["rack.session"] = Hash.new
149
+ get "/application_data_page/events/save", {}, env
150
+ redirect = last_response.headers['Location']
151
+ redirect.should eql('/application_data_page')
152
+ get redirect, {}, env
153
+ last_response.body.should == "<?xml version=\"1.0\"?>\n<html>\n <body>\n <p>here's a value</p>\n </body>\n</html>\n"
154
+ end
155
+
156
+ it "should have access to any application public methods" do
157
+ get "/application_method_page"
158
+ last_response.body.should == "<?xml version=\"1.0\"?>\n<html>\n <body>\n <p>Zaphod Beeblebrox</p>\n </body>\n</html>\n"
159
+ end
160
+
161
+ end
162
+
163
+ describe Trellis::Application, " with declared partial views" do
164
+ include Rack::Test::Methods
165
+
166
+ def app
167
+ TestApp::MyApp.new
168
+ end
169
+
170
+ it "should render a view defined in markaby" do
171
+ get "/partial_markaby"
172
+ last_response.body.should include("<p>This content was generated by Markaby</p>")
173
+ end
174
+
175
+ it "should render a view defined in haml" do
176
+ get "/partial_haml"
177
+ last_response.body.should include("<p>This content was generated by HAML</p>")
178
+ end
179
+
180
+ it "should render a view defined in textile" do
181
+ get "/partial_textile"
182
+ last_response.body.should include("<p>This content was generated by <strong>Textile</strong></p>")
183
+ end
184
+
185
+ it "should render a view defined in markdown" do
186
+ get "/partial_markdown"
187
+ last_response.body.should include("<h1>This content was generated by Markdown</h1>")
188
+ end
189
+
190
+ it "should render a view defined in eruby" do
191
+ get "/partial_eruby"
192
+ last_response.body.should include("<p>This content was generated by The Amazing ERubis</p>")
193
+ end
194
+
195
+ it "should render a view defined in eruby and have access to the surrounding context" do
196
+ get "/partial_eruby_loop"
197
+ last_response.body.join.should include("<ul> <li>ichi</li> <li>ni</li> <li>san</li> <li>shi</li> <li>go</li> <li>rokku</li> <li>hichi</li> <li>hachi</li> <li>kyu</li> <li>jyu</li> </ul>")
118
198
  end
119
- end
199
+
200
+ end
201
+
202
+ describe Trellis::Application, " with declared layout" do
203
+ include Rack::Test::Methods
204
+
205
+ def app
206
+ TestApp::MyApp.new
207
+ end
208
+
209
+ it "should render a page with its corresponding layout" do
210
+ get "/with_layout_static"
211
+ last_response.body.should include("<p>\n<h3>Hello Arizona!</h3></p>")
212
+ end
213
+
214
+ it "should render a page with its corresponding layout" do
215
+ get "/with_layout_variable"
216
+ last_response.body.should include("p>\n<h3>Hello Arizona!</h3></p>")
217
+ end
218
+
219
+ it "should render any embedded trellis components" do
220
+ get "/markaby_template_with_components"
221
+ last_response.body.should include("<p>Vulgar Vogons</p>")
222
+ end
223
+
224
+ it "should render and eruby template and layout" do
225
+ get '/eruby_template_and_layout'
226
+ last_response.body.join.should include("<ul> <li>one</li> <li>two</li> <li>tres</li> <li>cuatro</li> </ul>")
227
+ end
228
+ end
@@ -13,7 +13,7 @@ describe Trellis::Component, " in an application" do
13
13
 
14
14
  it "should return its intended content" do
15
15
  get '/'
16
- last_response.body.should eql('<html><body>hello from simple component</body></html>')
16
+ last_response.body.should include("hello from simple component")
17
17
  end
18
18
 
19
19
  it "should render each instance of a component in the template" do
@@ -65,17 +65,17 @@ describe Trellis::Component, " in an application" do
65
65
 
66
66
  it "should be able to provide a style link contribution to the page" do
67
67
  get '/page_with_contributions'
68
- last_response.body.should include('<link href="/someplace/my_styles.css" rel="stylesheet" type="text/css" />')
68
+ last_response.body.should include(%[<link href=\"/someplace/my_styles.css\" rel=\"stylesheet\" type=\"text/css\"/>])
69
69
  end
70
70
 
71
71
  it "should be able to provide a script link contribution to the page" do
72
72
  get '/page_with_contributions'
73
- last_response.body.should include('<script src="/someplace/my_script.js" type="text/javascript"></script>')
73
+ last_response.body.should include(%[<script src=\"/someplace/my_script.js\" type=\"text/javascript\"/>])
74
74
  end
75
75
 
76
76
  it "should be able to provide a style contribution to the page" do
77
77
  get '/page_with_contributions'
78
- last_response.body.should include('<style type="text/css">html { color:#555555; background-color:#303030; }</style>')
78
+ last_response.body.should include(%[<style type="text/css">html { color:#555555; background-color:#303030; }</style>])
79
79
  end
80
80
 
81
81
  it "should be able to provide a style contribution to the page per instance" do
@@ -123,32 +123,54 @@ end
123
123
 
124
124
  describe Class do
125
125
 
126
- it "when calling class_attr_accessor should add class attribute accessors for each symbol passed" do
126
+ it "should add class attribute accessors for each symbol passed when calling class_attr_accessor" do
127
127
  class Foo; end
128
128
  Foo.class_attr_accessor(:bar)
129
129
  Foo.should respond_to(:bar)
130
130
  Foo.should respond_to(:bar=)
131
131
  end
132
132
 
133
- it "when calling class_attr_reader should add class attribute readers for each symbol passed" do
133
+ it "should add class attribute readers for each symbol passed when calling class_attr_reader" do
134
134
  class Bar; end
135
135
  Bar.class_attr_reader(:foo)
136
136
  Bar.should respond_to(:foo)
137
137
  Bar.should_not respond_to(:foo=)
138
138
  end
139
139
 
140
- it "when calling class_attr_writer should add class attribute readers for each symbol passed" do
140
+ it "should add class attribute readers for each symbol passed when calling class_attr_writer" do
141
141
  class FooBar; end
142
142
  FooBar.class_attr_writer(:bar)
143
143
  FooBar.should_not respond_to(:bar)
144
144
  FooBar.should respond_to(:bar=)
145
145
  end
146
146
 
147
- it "when calling instance_attr_accessor should add instance attribute accessors for each symbol passed" do
147
+ it "should add instance attribute accessors for each symbol passed when calling instance_attr_accessor" do
148
148
  class Snafu; end
149
149
  Snafu.instance_attr_accessor(:bar)
150
150
  instance = Snafu.new
151
151
  instance.should respond_to(:bar)
152
152
  instance.should respond_to(:bar=)
153
153
  end
154
- end
154
+
155
+ end
156
+
157
+ describe Object do
158
+ before do
159
+ class Ini
160
+ def mini
161
+ "myni"
162
+ end
163
+ end
164
+ @instance = Ini.new
165
+ end
166
+
167
+ it "should invoke a method if available when calling call_if_provided" do
168
+ @instance.should respond_to(:call_if_provided)
169
+ @instance.call_if_provided(:mini).should eql("myni")
170
+ end
171
+
172
+ it "should not invoke a method if not available when calling call_if_provided" do
173
+ @instance.should respond_to(:call_if_provided)
174
+ @instance.call_if_provided(:moe).should be_nil
175
+ end
176
+ end
@@ -1,9 +1,26 @@
1
1
  module TestApp
2
2
  class MyApp < Trellis::Application
3
3
  home :home
4
+ persistent :my_field
4
5
 
5
6
  map_static ['/images', '/style', '/favicon.ico']
6
7
  map_static ['/jquery'], "./js"
8
+
9
+ MY_CONSTANT_1 = "it's just us, chickens!"
10
+
11
+ def application_method
12
+ "Zaphod Beeblebrox"
13
+ end
14
+
15
+ partial :partial_markaby do p "This content was generated by Markaby" end
16
+ partial :partial_haml, %[%p This content was generated by HAML], :format => :haml
17
+ partial :partial_textile, %[This content was generated by *Textile*], :format => :textile
18
+ partial :partial_markdown, %[# This content was generated by Markdown], :format => :markdown
19
+ partial :partial_eruby, %[<p>This content was generated by @{@my_variable}@</p>], :format => :eruby
20
+ partial :loop_body, %[<li>@{@i}@</li>], :format => :eruby
21
+
22
+ layout :main, %[<html><body><p>@!{@body}@</p></body></html>], :format => :eruby
23
+ layout(:other) { thtml { body { render_body }}}
7
24
  end
8
25
 
9
26
  class Home < Trellis::Page
@@ -28,6 +45,31 @@ module TestApp
28
45
  end
29
46
  end
30
47
 
48
+ class PageWithGetPlainText < Trellis::Page
49
+ pages :other
50
+
51
+ def get
52
+ "some content"
53
+ end
54
+ end
55
+
56
+ class PageWithGetRedirect < Trellis::Page
57
+ pages :other
58
+
59
+ def get
60
+ @other
61
+ end
62
+ end
63
+
64
+ class PageWithGetSame < Trellis::Page
65
+
66
+ def get
67
+ self
68
+ end
69
+
70
+ template do html { body { p "Vera, what has become of you?" }} end
71
+ end
72
+
31
73
  class Other < Trellis::Page
32
74
  template do html { body { p "Goodbye Cruel World " }} end
33
75
  end
@@ -39,7 +81,7 @@ module TestApp
39
81
  @some_value = "8675309"
40
82
  end
41
83
 
42
- template do html { body { text %[<trellis:value name="some_value"/>] }} end
84
+ template do thtml { body { text %[<trellis:value name="some_value"/>] }} end
43
85
  end
44
86
 
45
87
  class AfterLoad < Trellis::Page
@@ -49,7 +91,26 @@ module TestApp
49
91
  @some_value = "chunky bacon!"
50
92
  end
51
93
 
52
- template do html { body { text %[<trellis:value name="some_value"/>] }} end
94
+ template do thtml { body { text %[<trellis:value name="some_value"/>] }} end
95
+ end
96
+
97
+ class BeforeRender < Trellis::Page
98
+ attr_reader :some_value
99
+
100
+ def before_render
101
+ @some_value = "8675309"
102
+ end
103
+
104
+ template do thtml { body { text %[<trellis:value name="some_value"/>] }} end
105
+ end
106
+
107
+ class AfterRender < Trellis::Page
108
+
109
+ def after_render
110
+ @application.my_field = "changed in after_render method"
111
+ end
112
+
113
+ template do thtml { body { p { "hey!"} }} end
53
114
  end
54
115
 
55
116
  class RoutedDifferently < Trellis::Page
@@ -62,7 +123,7 @@ module TestApp
62
123
  route '/hello/:name'
63
124
 
64
125
  template do
65
- html {
126
+ thtml {
66
127
  body {
67
128
  h2 "Hello"
68
129
  text %[<trellis:value name="salutation"/><trellis:value name="name"/>]
@@ -75,7 +136,7 @@ module TestApp
75
136
  route '/report/:year/:month/:day'
76
137
 
77
138
  template do
78
- html {
139
+ thtml {
79
140
  body {
80
141
  h2 "Report for"
81
142
  text %[<trellis:value name="month"/>]
@@ -92,7 +153,7 @@ module TestApp
92
153
  route '/foobar/?:foo?/?:bar?'
93
154
 
94
155
  template do
95
- html {
156
+ thtml {
96
157
  body {
97
158
  text %[<trellis:value name="foo"/>]
98
159
  text '-'
@@ -106,7 +167,7 @@ module TestApp
106
167
  route '/splat/*'
107
168
 
108
169
  template do
109
- html {
170
+ thtml {
110
171
  body {
111
172
  text %[<trellis:value name="splat"/>]
112
173
  }
@@ -118,7 +179,7 @@ module TestApp
118
179
  route '/splats/*/foo/*/*'
119
180
 
120
181
  template do
121
- html {
182
+ thtml {
122
183
  body {
123
184
  text %[<trellis:value name="splat"/>]
124
185
  }
@@ -130,7 +191,7 @@ module TestApp
130
191
  route '/mixed/:foo/*'
131
192
 
132
193
  template do
133
- html {
194
+ thtml {
134
195
  body {
135
196
  text %[<trellis:value name="splat"/>]
136
197
  text '-'
@@ -144,7 +205,7 @@ module TestApp
144
205
  route '/foobar/:foo/:bar'
145
206
 
146
207
  template do
147
- html {
208
+ thtml {
148
209
  body {
149
210
  text %[<trellis:value name="foo"/>]
150
211
  text '-'
@@ -158,7 +219,7 @@ module TestApp
158
219
  route '/downloads/:file.:ext'
159
220
 
160
221
  template do
161
- html {
222
+ thtml {
162
223
  body {
163
224
  text %[<trellis:value name="file"/>]
164
225
  text '-'
@@ -170,11 +231,11 @@ module TestApp
170
231
 
171
232
  class SamplePage < Trellis::Page
172
233
  attr_accessor :value
173
- template do html { body { text %[<trellis:value name="value"/>] }} end
234
+ template do thtml { body { text %[<trellis:value name="value"/>] }} end
174
235
  end
175
236
 
176
237
  class AnotherSamplePage < Trellis::Page
177
- template do html { body { text %[<trellis:value name="page_name"/>] }} end
238
+ template do thtml { body { text %[<trellis:value name="page_name"/>] }} end
178
239
  end
179
240
 
180
241
  class HamlPage < Trellis::Page
@@ -197,7 +258,7 @@ module TestApp
197
258
  end
198
259
 
199
260
  class MarkDownPage < Trellis::Page
200
- template "# This is the Title\n## This is the SubTitle\nThis is some text", :format => :markdown
261
+ template %[# This is the Title\n## This is the SubTitle\n**This is some text**], :format => :markdown
201
262
  end
202
263
 
203
264
  class HTMLPage < Trellis::Page
@@ -214,5 +275,151 @@ module TestApp
214
275
 
215
276
  template %[<html><body><ul><?rb for item in @list ?><li>@{item}@</li><?rb end ?></ul></body></html>], :format => :eruby
216
277
  end
278
+
279
+ class ConstantAccessPage < Trellis::Page
280
+ def greet
281
+ "helloooo, la la la"
282
+ end
283
+
284
+ template %[<html><body><p>@{TestApp::MyApp::MY_CONSTANT_1}@</p></body></html>], :format => :eruby
285
+ end
286
+
287
+ class MethodAccessPage < Trellis::Page
288
+ def greet
289
+ "helloooo, la la la"
290
+ end
291
+
292
+ template %[<html><body><p>@{greet}@</p></body></html>], :format => :eruby
293
+ end
294
+
295
+ class ApplicationDataPage < Trellis::Page
296
+
297
+ def on_save
298
+ @application.my_field = "here's a value"
299
+ self
300
+ end
301
+
302
+ template %[<html><body><p>@{@application.my_field}@</p></body></html>], :format => :eruby
303
+ end
304
+
305
+ class ApplicationMethodPage < Trellis::Page
306
+ template %[<html><body><p>@{application_method()}@</p></body></html>], :format => :eruby
307
+ end
308
+
309
+ class PageWithGetAndExplicitRedirect < Trellis::Page
310
+ route '/explicit_redirect'
311
+
312
+ def get
313
+ redirect "/hello/Ford%20Prefect"
314
+ end
315
+ end
316
+
317
+ class PartialMarkabyPage < Trellis::Page
318
+ route '/partial_markaby'
319
+ template %[<html><body>@!{render_partial(:partial_markaby)}@</body></html>], :format => :eruby
320
+ end
321
+
322
+ class PartialHamlPage < Trellis::Page
323
+ route '/partial_haml'
324
+ template %[<html><body>@!{render_partial(:partial_haml)}@</body></html>], :format => :eruby
325
+ end
326
+
327
+ class PartialTextilePage < Trellis::Page
328
+ route '/partial_textile'
329
+ template %[<html><body>@!{render_partial(:partial_textile)}@</body></html>], :format => :eruby
330
+ end
331
+
332
+ class PartialMarkdownPage < Trellis::Page
333
+ route '/partial_markdown'
334
+ template %[<html><body>@!{render_partial(:partial_markdown)}@</body></html>], :format => :eruby
335
+ end
336
+
337
+ class PartialErubyPage < Trellis::Page
338
+ route '/partial_eruby'
339
+
340
+ def get
341
+ @my_variable = 'The Amazing ERubis'
342
+ self
343
+ end
344
+
345
+ template %[<html><body>@!{render_partial(:partial_eruby)}@</body></html>], :format => :eruby
346
+ end
347
+
348
+ class PartialErubyLoopPage < Trellis::Page
349
+ route '/partial_eruby_loop'
350
+
351
+ def get
352
+ @elements = ['ichi', 'ni', 'san', 'shi', 'go', 'rokku', 'hichi', 'hachi', 'kyu', 'jyu']
353
+ self
354
+ end
355
+
356
+ template %[<html>
357
+ <body>
358
+ <ul>
359
+ <?rb @elements.each do |element| ?>
360
+ @!{ render_partial(:loop_body, {:i, element}) }@
361
+ <?rb end ?>
362
+ </ul>
363
+ </body>
364
+ </html>], :format => :eruby
365
+ end
366
+
367
+ class PageWithLayoutStatic < Trellis::Page
368
+ route '/with_layout_static'
369
+ template %[<h3>Hello Arizona!</h3>], :format => :eruby, :layout => :main
370
+ end
371
+
372
+ class PageWithLayoutDynamic < Trellis::Page
373
+ route '/with_layout_variable'
374
+
375
+ def get
376
+ @my_value = "Hello Arizona!"
377
+ self
378
+ end
379
+
380
+ template %[<h3>@{@my_value}@</h3>], :format => :eruby, :layout => :main
381
+ end
382
+
383
+ class MarkabyTemplateWithComponents < Trellis::Page
384
+ attr_reader :some_value
385
+
386
+ def get
387
+ @some_value = "Vulgar Vogons"
388
+ self
389
+ end
390
+
391
+ template(nil, :layout => :other) do p { text %[<trellis:value name="some_value"/>] } end
392
+ end
393
+
394
+ class ErubyTemplateAndLayout < Trellis::Page
395
+ def get
396
+ @elements = ['one', 'two', 'tres', 'cuatro']
397
+ self
398
+ end
399
+
400
+ template %[
401
+ <ul>
402
+ <?rb @elements.each do |element| ?>
403
+ @!{ render_partial(:loop_body, {:i, element}) }@
404
+ <?rb end ?>
405
+ </ul>
406
+ ], :format => :eruby, :layout => :main
407
+ end
408
+
409
+ class PostOriginPage < Trellis::Page
410
+ route '/admin/login'
411
+ pages :post_redirect_page
412
+
413
+ def on_submit_from_login
414
+ redirect '/admin/result'
415
+ end
416
+
417
+ template %[<html><body><h1>PostOriginPage</h1></body></html>]
418
+ end
419
+
420
+ class PostRedirectPage < Trellis::Page
421
+ route '/admin/result'
422
+ template %[<html><body><h1>PostRedirectPage</h1></body></html>]
423
+ end
217
424
 
218
425
  end