erector 0.3.105 → 0.3.110

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.
data/lib/erector.rb CHANGED
@@ -12,5 +12,5 @@ require "erector/widgets"
12
12
  ##
13
13
  # Erector view framework
14
14
  module Erector
15
- VERSION = "0.3.105"
15
+ VERSION = "0.3.110"
16
16
  end
@@ -25,6 +25,8 @@ module ActionView #:nodoc:
25
25
  full_path = "#{view_path}/#{template_path}.rb"
26
26
  if File.exists?(full_path)
27
27
  require_dependency full_path
28
+ found = true
29
+ break
28
30
  else
29
31
  partial_file_path = full_path.gsub(/\/([^\/]*)$/, '/_\1')
30
32
  if File.exists?(partial_file_path)
@@ -61,3 +63,4 @@ ActionView::Base.instance_eval do
61
63
  register_template_handler :rb, ActionView::TemplateHandlers::Erector
62
64
  end
63
65
  end
66
+ # ActionMailer::Base.register_template_extension('rb')
@@ -47,8 +47,6 @@ module Erector
47
47
  # return text, take block
48
48
  [
49
49
  :link_to_function,
50
- :form_for,
51
- :form_tag,
52
50
  :text_field_tag,
53
51
  :password_field_tag,
54
52
  :check_box_tag
@@ -63,7 +61,9 @@ module Erector
63
61
 
64
62
  # render text, take block
65
63
  [
66
- :error_messages_for,
64
+ :error_messages_for,
65
+ :form_tag,
66
+ :form_for,
67
67
  ].each do |method_to_proxy_with_block|
68
68
  method_def =<<-METHOD_DEF
69
69
  def #{method_to_proxy_with_block}(*args, &block)
@@ -312,20 +312,24 @@ protected
312
312
  # override concat on the helpers object (which is usually a Rails view object)
313
313
  unless @helpers.respond_to?(:concat_without_erector)
314
314
  @helpers.metaclass.class_eval do
315
- # alias_method :capture_without_erector, :capture
316
- # define_method :capture do |*args|
317
- # result = nil
318
- # widget = @erector_widget_stack.first
319
- # begin
320
- # original_doc = widget.doc
321
- # widget.doc = HtmlParts.new
322
- # capture_without_erector(*args)
323
- # result = raw(widget.doc.to_s)
324
- # ensure
325
- # widget.doc = original_doc
326
- # end
327
- # result
328
- # end
315
+ alias_method :capture_without_erector, :capture
316
+ def capture(*args, &block)
317
+ result = nil
318
+ widget = @erector_widget_stack.first
319
+ begin
320
+ original_doc = widget.doc
321
+ widget.instance_eval do
322
+ @doc = HtmlParts.new
323
+ end
324
+ captured = capture_without_erector(*args, &block)
325
+ result = widget.raw(widget.doc.to_s)
326
+ ensure
327
+ widget.instance_eval do
328
+ @doc = original_doc
329
+ end
330
+ end
331
+ result
332
+ end
329
333
 
330
334
  alias_method :concat_without_erector, :concat
331
335
  define_method :concat do |*args|
@@ -23,76 +23,78 @@ module RailsHelpersSpec
23
23
  @controller.append_view_path("#{RAILS_ROOT}/app/views")
24
24
  end
25
25
 
26
- it "image_tag" do
27
- class Erector::TestWidget < Erector::Widget
28
- def render
29
- image_tag("rails.png")
30
- end
31
- end
32
- @controller.render :widget => Erector::TestWidget
33
- @response.body.should == "<img alt=\"Rails\" src=\"/images/rails.png\" />"
34
- end
26
+ describe "returning raw text" do
27
+ it "image_tag" do
28
+ class Erector::TestWidget < Erector::Widget
29
+ def render
30
+ image_tag("rails.png")
31
+ end
32
+ end
33
+ @controller.render :widget => Erector::TestWidget
34
+ @response.body.should == "<img alt=\"Rails\" src=\"/images/rails.png\" />"
35
+ end
35
36
 
36
- it "javascript_include_tag" do
37
- class Erector::TestWidget < Erector::Widget
38
- def render
39
- javascript_include_tag("rails")
40
- end
41
- end
42
- @controller.render :widget => Erector::TestWidget
43
- @response.body.should == "<script src=\"/javascripts/rails.js\" type=\"text/javascript\"></script>"
44
- end
37
+ it "javascript_include_tag" do
38
+ class Erector::TestWidget < Erector::Widget
39
+ def render
40
+ javascript_include_tag("rails")
41
+ end
42
+ end
43
+ @controller.render :widget => Erector::TestWidget
44
+ @response.body.should == "<script src=\"/javascripts/rails.js\" type=\"text/javascript\"></script>"
45
+ end
45
46
 
46
- it "define_javascript_functions" do
47
- class Erector::TestWidget < Erector::Widget
48
- def render
49
- define_javascript_functions
47
+ it "define_javascript_functions" do
48
+ class Erector::TestWidget < Erector::Widget
49
+ def render
50
+ define_javascript_functions
51
+ end
50
52
  end
51
- end
52
- @controller.render :widget => Erector::TestWidget
53
- @response.body.should =~ /^<script type=\"text\/javascript\">\n/
54
- end
53
+ @controller.render :widget => Erector::TestWidget
54
+ @response.body.should =~ /^<script type=\"text\/javascript\">\n/
55
+ end
55
56
 
56
- it "stylesheet_link_tag" do
57
- class Erector::TestWidget < Erector::Widget
58
- def render
59
- stylesheet_link_tag("rails")
60
- end
61
- end
62
- @controller.render :widget => Erector::TestWidget
63
- @response.body.should == "<link href=\"/stylesheets/rails.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />"
64
- end
57
+ it "stylesheet_link_tag" do
58
+ class Erector::TestWidget < Erector::Widget
59
+ def render
60
+ stylesheet_link_tag("rails")
61
+ end
62
+ end
63
+ @controller.render :widget => Erector::TestWidget
64
+ @response.body.should == "<link href=\"/stylesheets/rails.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />"
65
+ end
65
66
 
66
- def sortable_js_for(element_id, url)
67
- "Sortable.create(\"#{element_id}\", {onUpdate:function(){new Ajax.Request('#{url}', {asynchronous:true, evalScripts:true, parameters:Sortable.serialize(\"#{element_id}\")})}})"
68
- end
67
+ def sortable_js_for(element_id, url)
68
+ "Sortable.create(\"#{element_id}\", {onUpdate:function(){new Ajax.Request('#{url}', {asynchronous:true, evalScripts:true, parameters:Sortable.serialize(\"#{element_id}\")})}})"
69
+ end
69
70
 
70
- it "sortable_element" do
71
- class Erector::TestWidget < Erector::Widget
72
- def render
73
- sortable_element("rails", :url => "/foo")
74
- end
75
- end
76
- @controller.render :widget => Erector::TestWidget
77
- @response.body.should ==
78
- "<script type=\"text/javascript\">\n//<![CDATA[\n" +
79
- sortable_js_for("rails", "/foo") +
80
- "\n//]]>\n</script>"
81
- end
71
+ it "sortable_element" do
72
+ class Erector::TestWidget < Erector::Widget
73
+ def render
74
+ sortable_element("rails", :url => "/foo")
75
+ end
76
+ end
77
+ @controller.render :widget => Erector::TestWidget
78
+ @response.body.should ==
79
+ "<script type=\"text/javascript\">\n//<![CDATA[\n" +
80
+ sortable_js_for("rails", "/foo") +
81
+ "\n//]]>\n</script>"
82
+ end
82
83
 
83
- it "sortable_element_js" do
84
- class Erector::TestWidget < Erector::Widget
85
- def render
86
- sortable_element_js("rails", :url => "/foo")
87
- end
88
- end
89
- @controller.render :widget => Erector::TestWidget
90
- @response.body.should == sortable_js_for("rails", "/foo") + ";"
84
+ it "sortable_element_js" do
85
+ class Erector::TestWidget < Erector::Widget
86
+ def render
87
+ sortable_element_js("rails", :url => "/foo")
88
+ end
89
+ end
90
+ @controller.render :widget => Erector::TestWidget
91
+ @response.body.should == sortable_js_for("rails", "/foo") + ";"
91
92
 
92
- end
93
-
94
- #Note: "text_field_with_auto_complete" is now a plugin, which makes it difficult to test inside the Erector project
93
+ end
95
94
 
95
+ #Note: "text_field_with_auto_complete" is now a plugin, which makes it difficult to test inside the Erector project
96
+ end
97
+
96
98
  # :link_to_function,
97
99
  # :link_to,
98
100
  # :link_to_remote,
@@ -34,12 +34,13 @@ describe "a view" do
34
34
  end
35
35
 
36
36
  it "renders error messages" do
37
- pending("error_messages_for is broken")
37
+ pending("error_messages_for is broken") do
38
38
  message = Erector::Widget.new(@view) do
39
39
  error_messages_for(:model)
40
40
  end.to_s
41
41
  message.should include("too silly")
42
42
  message.should include("1 error")
43
+ end
43
44
  end
44
45
 
45
46
  end
@@ -63,7 +64,6 @@ describe "a view" do
63
64
  end
64
65
 
65
66
  it "renders non-forgery-protected forms via form_tag" do
66
- pending("needs ActionView::capture to work")
67
67
  class << @view
68
68
  def protect_against_forgery?
69
69
  false
@@ -78,7 +78,6 @@ describe "a view" do
78
78
  end
79
79
 
80
80
  it "renders forgery-protected forms via form_tag" do
81
- pending("needs ActionView::capture to work")
82
81
  class << @view
83
82
  def protect_against_forgery?
84
83
  true
@@ -94,9 +93,7 @@ describe "a view" do
94
93
  end
95
94
 
96
95
  Erector::Widget.new(@view) do
97
- puts "starting"
98
96
  form_tag("/foo") do
99
- puts "start of block"
100
97
  p "I'm in a form"
101
98
  end
102
99
  end.to_s.should == "<form action=\"/foo\" method=\"post\"><div style=\"margin:0;padding:0\"><input name=\"\" type=\"hidden\" value=\"token\" /></div><p>I'm in a form</p></form>"
data/spec/spec_helper.rb CHANGED
@@ -19,3 +19,22 @@ module Views
19
19
  module TemplateHandlerSpec
20
20
  end
21
21
  end
22
+
23
+
24
+ # uncomment this to find leftover debug putses
25
+ #
26
+ # alias :original_puts :puts
27
+ # def puts(string ="")
28
+ # super string.to_s + "\s(#{caller.first.match(/(\w+\.\w+:\d+)|Rakefile:\d+/)[0]})"
29
+ # end
30
+ #
31
+ # alias :original_p :p
32
+ # def p(string="")
33
+ # original_puts "\s(#{caller.first.match(/(\w+\.\w+:\d+)|Rakefile:\d+/)[0]})"
34
+ # super(string)
35
+ # end
36
+ #
37
+ # alias :original_print :print
38
+ # def print(string="")
39
+ # super string + "\s(#{caller.first.match(/(\w+\.\w+:\d+)|Rakefile:\d+/)[0]})"
40
+ # end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: erector
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.105
4
+ version: 0.3.110
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pivotal Labs