markaby 0.7.0 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +4 -0
- data/Markaby.gemspec +4 -2
- data/VERSION +1 -1
- data/lib/markaby/rails/rails_builder.rb +18 -1
- data/spec/markaby/rails/views/markaby/_form_for_with_body_in_erb.erb +1 -0
- data/spec/markaby/rails/views/markaby/renders_form_for_with_erb_body.mab +3 -0
- data/spec/markaby/rails_spec.rb +25 -6
- data/spec/markaby/sinatra/sinatra_spec.rb +55 -52
- data/spec/spec_helper.rb +1 -1
- metadata +6 -4
data/CHANGELOG.rdoc
CHANGED
data/Markaby.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{markaby}
|
8
|
-
s.version = "0.7.
|
8
|
+
s.version = "0.7.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["_why", "Tim Fletcher", "John Barton", "spox", "smtlaissezfaire"]
|
12
|
-
s.date = %q{2010-08-
|
12
|
+
s.date = %q{2010-08-19}
|
13
13
|
s.description = %q{Tim Fletcher and _why's ruby driven HTML templating system}
|
14
14
|
s.email = %q{scott@railsnewbie.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -44,6 +44,7 @@ Gem::Specification.new do |s|
|
|
44
44
|
"spec/markaby/rails/spec_helper.rb",
|
45
45
|
"spec/markaby/rails/views/layouts/layout.mab",
|
46
46
|
"spec/markaby/rails/views/markaby/_a_partial.mab",
|
47
|
+
"spec/markaby/rails/views/markaby/_form_for_with_body_in_erb.erb",
|
47
48
|
"spec/markaby/rails/views/markaby/_partial_child_with_locals.mab",
|
48
49
|
"spec/markaby/rails/views/markaby/access_to_helpers.mab",
|
49
50
|
"spec/markaby/rails/views/markaby/broken.mab",
|
@@ -61,6 +62,7 @@ Gem::Specification.new do |s|
|
|
61
62
|
"spec/markaby/rails/views/markaby/render_mab_without_explicit_render_call.mab",
|
62
63
|
"spec/markaby/rails/views/markaby/render_with_ivar.mab",
|
63
64
|
"spec/markaby/rails/views/markaby/renders_erb.rhtml",
|
65
|
+
"spec/markaby/rails/views/markaby/renders_form_for_with_erb_body.mab",
|
64
66
|
"spec/markaby/rails/views/markaby/routes.mab",
|
65
67
|
"spec/markaby/rails/views/markaby/yielding.mab",
|
66
68
|
"spec/markaby/rails/views/markaby/yielding_content_for_with_block_helper.mab",
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.7.
|
1
|
+
0.7.1
|
@@ -64,9 +64,26 @@ module Markaby
|
|
64
64
|
|
65
65
|
private
|
66
66
|
|
67
|
+
if ::Rails::VERSION::STRING == "2.2.0"
|
68
|
+
def __template__
|
69
|
+
@view.instance_variable_get("@_last_render")
|
70
|
+
end
|
71
|
+
else
|
72
|
+
def __template__
|
73
|
+
@view.template
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
67
77
|
def method_missing(sym, *args, &block)
|
68
78
|
result = @proxied_object.__send__(sym, *args, &block)
|
69
|
-
|
79
|
+
|
80
|
+
# a markaby template may call render :partial with the form proxy helper.
|
81
|
+
# we only want to manually concat _if_ we are in a markaby template (not, say, erb)
|
82
|
+
if __template__.extension == "mab"
|
83
|
+
@view.concat(result)
|
84
|
+
end
|
85
|
+
|
86
|
+
result
|
70
87
|
end
|
71
88
|
end
|
72
89
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= f.text_field :foo %>
|
data/spec/markaby/rails_spec.rb
CHANGED
@@ -153,6 +153,14 @@ if RUNNING_RAILS
|
|
153
153
|
render :layout => "layout.mab",
|
154
154
|
:template => "markaby/double_output"
|
155
155
|
end
|
156
|
+
|
157
|
+
def renders_form_for_with_erb_body
|
158
|
+
@obj = Object.new
|
159
|
+
|
160
|
+
def @obj.foo
|
161
|
+
"bar"
|
162
|
+
end
|
163
|
+
end
|
156
164
|
end
|
157
165
|
|
158
166
|
class MarkabyOnRailsTest < ActionController::TestCase
|
@@ -254,7 +262,7 @@ if RUNNING_RAILS
|
|
254
262
|
get :routes
|
255
263
|
assert_response :success
|
256
264
|
|
257
|
-
expected_output =
|
265
|
+
expected_output = '<a href="/users/new">Foo</a>'
|
258
266
|
assert_equal expected_output, @response.body
|
259
267
|
end
|
260
268
|
|
@@ -280,7 +288,7 @@ if RUNNING_RAILS
|
|
280
288
|
|
281
289
|
assert_response :success
|
282
290
|
|
283
|
-
assert_equal
|
291
|
+
assert_equal '<form action="/markaby/render_form_for_with_fields" method="post"><input id="foo_foo" name="foo[foo]" size="30" type="text" /></form>',
|
284
292
|
@response.body
|
285
293
|
end
|
286
294
|
|
@@ -289,10 +297,10 @@ if RUNNING_RAILS
|
|
289
297
|
|
290
298
|
assert_response :success
|
291
299
|
|
292
|
-
expected_output =
|
293
|
-
expected_output <<
|
294
|
-
expected_output <<
|
295
|
-
expected_output <<
|
300
|
+
expected_output = '<form action="/markaby/render_form_for_with_multiple_fields" method="post">'
|
301
|
+
expected_output << '<input id="foo_foo" name="foo[foo]" size="30" type="text" />'
|
302
|
+
expected_output << '<input id="foo_baz" name="foo[baz]" size="30" type="text" />'
|
303
|
+
expected_output << '</form>'
|
296
304
|
|
297
305
|
assert_equal expected_output,
|
298
306
|
@response.body
|
@@ -350,6 +358,17 @@ if RUNNING_RAILS
|
|
350
358
|
|
351
359
|
assert_equal expected_output, @response.body
|
352
360
|
end
|
361
|
+
|
362
|
+
def test_renders_form_for_with_erb_render_in_body
|
363
|
+
get :renders_form_for_with_erb_body
|
364
|
+
assert_response :success
|
365
|
+
|
366
|
+
str = '<form action="/markaby/renders_form_for_with_erb_body" method="post">'
|
367
|
+
str << '<input id="foo_foo" name="foo[foo]" size="30" type="text" />'
|
368
|
+
str << '</form>'
|
369
|
+
|
370
|
+
assert_equal str, @response.body
|
371
|
+
end
|
353
372
|
end
|
354
373
|
end
|
355
374
|
|
@@ -1,64 +1,67 @@
|
|
1
|
-
|
2
|
-
require File.expand_path(File.dirname(__FILE__) + "
|
3
|
-
require '
|
1
|
+
unless RUNNING_RAILS
|
2
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
|
3
|
+
require 'markaby/sinatra'
|
4
|
+
require 'rack/test'
|
5
|
+
require File.expand_path(File.dirname(__FILE__) + "/app")
|
4
6
|
|
5
|
-
describe "sinatra integration" do
|
6
|
-
|
7
|
+
describe "sinatra integration" do
|
8
|
+
include Rack::Test::Methods
|
7
9
|
|
8
|
-
|
9
|
-
|
10
|
-
|
10
|
+
def app
|
11
|
+
@app ||= Sinatra::Application
|
12
|
+
end
|
11
13
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
14
|
+
it "should render an empty" do
|
15
|
+
get '/empty_action'
|
16
|
+
last_response.should be_ok
|
17
|
+
end
|
16
18
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
19
|
+
it "should render an empty markaby template" do
|
20
|
+
get '/markaby_template'
|
21
|
+
last_response.should be_ok
|
22
|
+
last_response.body.should == ""
|
23
|
+
end
|
22
24
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
25
|
+
it "should render a template with html in it" do
|
26
|
+
get '/simple_html'
|
27
|
+
last_response.should be_ok
|
28
|
+
last_response.body.should == "<ul><li>hi</li><li>there</li></ul>"
|
29
|
+
end
|
28
30
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
31
|
+
it "should be able to pass variables" do
|
32
|
+
get '/variables'
|
33
|
+
last_response.should be_ok
|
34
|
+
last_response.body.should == '<p class="name">Scott Taylor</p>'
|
35
|
+
end
|
34
36
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
37
|
+
it "should be able to pass variables through locals" do
|
38
|
+
get '/variables_with_locals'
|
39
|
+
last_response.should be_ok
|
40
|
+
last_response.body.should == '<p class="name">Scott Taylor</p>'
|
41
|
+
end
|
40
42
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
43
|
+
it "should have scope to instance variables" do
|
44
|
+
get '/scope_instance_variables'
|
45
|
+
last_response.should be_ok
|
46
|
+
last_response.body.should == '<p class="name">Scott Taylor</p>'
|
47
|
+
end
|
46
48
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
49
|
+
it "should be able to use named templates" do
|
50
|
+
get "/named_template"
|
51
|
+
last_response.should be_ok
|
52
|
+
last_response.body.should == '<div class="title">Hello World!</div>'
|
53
|
+
end
|
52
54
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
55
|
+
it "should be able to use a layout with :layout" do
|
56
|
+
get '/layout'
|
57
|
+
last_response.should be_ok
|
58
|
+
last_response.body.should == '<html><div class="title">Hello World!</div></html>'
|
59
|
+
end
|
58
60
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
61
|
+
it "should be able to access helpers in a template" do
|
62
|
+
get '/helpers'
|
63
|
+
last_response.should be_ok
|
64
|
+
last_response.body.should == "<li>bacon</li>"
|
65
|
+
end
|
63
66
|
end
|
64
|
-
end
|
67
|
+
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: markaby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 1
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 7
|
9
|
-
-
|
10
|
-
version: 0.7.
|
9
|
+
- 1
|
10
|
+
version: 0.7.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- _why
|
@@ -19,7 +19,7 @@ autorequire:
|
|
19
19
|
bindir: bin
|
20
20
|
cert_chain: []
|
21
21
|
|
22
|
-
date: 2010-08-
|
22
|
+
date: 2010-08-19 00:00:00 -04:00
|
23
23
|
default_executable:
|
24
24
|
dependencies:
|
25
25
|
- !ruby/object:Gem::Dependency
|
@@ -75,6 +75,7 @@ files:
|
|
75
75
|
- spec/markaby/rails/spec_helper.rb
|
76
76
|
- spec/markaby/rails/views/layouts/layout.mab
|
77
77
|
- spec/markaby/rails/views/markaby/_a_partial.mab
|
78
|
+
- spec/markaby/rails/views/markaby/_form_for_with_body_in_erb.erb
|
78
79
|
- spec/markaby/rails/views/markaby/_partial_child_with_locals.mab
|
79
80
|
- spec/markaby/rails/views/markaby/access_to_helpers.mab
|
80
81
|
- spec/markaby/rails/views/markaby/broken.mab
|
@@ -92,6 +93,7 @@ files:
|
|
92
93
|
- spec/markaby/rails/views/markaby/render_mab_without_explicit_render_call.mab
|
93
94
|
- spec/markaby/rails/views/markaby/render_with_ivar.mab
|
94
95
|
- spec/markaby/rails/views/markaby/renders_erb.rhtml
|
96
|
+
- spec/markaby/rails/views/markaby/renders_form_for_with_erb_body.mab
|
95
97
|
- spec/markaby/rails/views/markaby/routes.mab
|
96
98
|
- spec/markaby/rails/views/markaby/yielding.mab
|
97
99
|
- spec/markaby/rails/views/markaby/yielding_content_for_with_block_helper.mab
|