markaby 0.7.0 → 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,7 @@
1
+ = 0.7.1 (2010-08-19)
2
+
3
+ * Rails fixes for form_for called from erb templates
4
+
1
5
  = 0.7.0
2
6
 
3
7
  * Sinatra 1.0 support
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{markaby}
8
- s.version = "0.7.0"
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-15}
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.0
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
- @view.concat(result)
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 %>
@@ -0,0 +1,3 @@
1
+ form_for :foo do |f|
2
+ render :partial => "form_for_with_body_in_erb", :locals => { :f => f }
3
+ end
@@ -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 = "<a href=\"/users/new\">Foo</a>"
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 "<form action=\"/markaby/render_form_for_with_fields\" method=\"post\"><input id=\"foo_foo\" name=\"foo[foo]\" size=\"30\" type=\"text\" /></form>",
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 = "<form action=\"/markaby/render_form_for_with_multiple_fields\" method=\"post\">"
293
- expected_output << "<input id=\"foo_foo\" name=\"foo[foo]\" size=\"30\" type=\"text\" />"
294
- expected_output << "<input id=\"foo_baz\" name=\"foo[baz]\" size=\"30\" type=\"text\" />"
295
- expected_output << "</form>"
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
- require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
2
- require File.expand_path(File.dirname(__FILE__) + "/app")
3
- require 'rack/test'
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
- include Rack::Test::Methods
7
+ describe "sinatra integration" do
8
+ include Rack::Test::Methods
7
9
 
8
- def app
9
- @app ||= Sinatra::Application
10
- end
10
+ def app
11
+ @app ||= Sinatra::Application
12
+ end
11
13
 
12
- it "should render an empty" do
13
- get '/empty_action'
14
- last_response.should be_ok
15
- end
14
+ it "should render an empty" do
15
+ get '/empty_action'
16
+ last_response.should be_ok
17
+ end
16
18
 
17
- it "should render an empty markaby template" do
18
- get '/markaby_template'
19
- last_response.should be_ok
20
- last_response.body.should == ""
21
- end
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
- it "should render a template with html in it" do
24
- get '/simple_html'
25
- last_response.should be_ok
26
- last_response.body.should == "<ul><li>hi</li><li>there</li></ul>"
27
- end
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
- it "should be able to pass variables" do
30
- get '/variables'
31
- last_response.should be_ok
32
- last_response.body.should == '<p class="name">Scott Taylor</p>'
33
- end
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
- it "should be able to pass variables through locals" do
36
- get '/variables_with_locals'
37
- last_response.should be_ok
38
- last_response.body.should == '<p class="name">Scott Taylor</p>'
39
- end
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
- it "should have scope to instance variables" do
42
- get '/scope_instance_variables'
43
- last_response.should be_ok
44
- last_response.body.should == '<p class="name">Scott Taylor</p>'
45
- end
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
- it "should be able to use named templates" do
48
- get "/named_template"
49
- last_response.should be_ok
50
- last_response.body.should == '<div class="title">Hello World!</div>'
51
- end
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
- it "should be able to use a layout with :layout" do
54
- get '/layout'
55
- last_response.should be_ok
56
- last_response.body.should == '<html><div class="title">Hello World!</div></html>'
57
- end
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
- it "should be able to access helpers in a template" do
60
- get '/helpers'
61
- last_response.should be_ok
62
- last_response.body.should == "<li>bacon</li>"
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
@@ -8,8 +8,8 @@ require 'markaby'
8
8
  require 'markaby/kernel_method'
9
9
  require 'markaby/rails'
10
10
 
11
- require 'markaby/sinatra'
12
11
  require 'erb'
12
+ require 'markaby/rails/spec_helper'
13
13
 
14
14
  module MarkabyTestHelpers
15
15
  def link_to(obj)
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: 3
4
+ hash: 1
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 7
9
- - 0
10
- version: 0.7.0
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-15 00:00:00 -04:00
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