padrino-helpers 0.8.1 → 0.8.2

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.8.1
1
+ 0.8.2
@@ -122,13 +122,18 @@ module Padrino
122
122
  !@_out_buf.nil?
123
123
  end
124
124
 
125
- ##
126
- # Used to determine if a block is called from ERB.
127
- # NOTE: This doesn't actually work yet because the variable __in_erb_template
128
- # hasn't been defined in ERB. We need to find a way to fix this.
129
- #
130
- def block_is_erb?(block)
131
- has_erb_buffer? || block && eval('defined? __in_erb_template', block)
125
+ if RUBY_VERSION < '1.9.0'
126
+ # Check whether we're called from an erb template.
127
+ # We'd return a string in any other case, but erb <%= ... %>
128
+ # can't take an <% end %> later on, so we have to use <% ... %>
129
+ # and implicitly concat.
130
+ def block_is_erb?(block)
131
+ has_erb_buffer? || block && eval('defined? __in_erb_template', block)
132
+ end
133
+ else
134
+ def block_is_erb?(block)
135
+ has_erb_buffer? || block && eval('defined? __in_erb_template', block.binding)
136
+ end
132
137
  end
133
138
 
134
139
  ##
@@ -40,6 +40,7 @@ module Padrino
40
40
  #
41
41
  def tag(name, options={})
42
42
  content, open_tag = options.delete(:content), options.delete(:open)
43
+ content = content.join("\n") if content.respond_to?(:join)
43
44
  identity_tag_attributes.each { |attr| options[attr] = attr.to_s if options[attr] }
44
45
  html_attrs = options.collect { |a, v| v.blank? ? nil : "#{a}=\"#{v}\"" }.compact.join(" ")
45
46
  base_tag = (html_attrs.present? ? "<#{name} #{html_attrs}" : "<#{name}")
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{padrino-helpers}
8
- s.version = "0.8.1"
8
+ s.version = "0.8.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Padrino Team", "Nathan Esquenazi", "Davide D'Agostino", "Arthur Chiu"]
12
- s.date = %q{2010-02-14}
12
+ s.date = %q{2010-02-17}
13
13
  s.description = %q{Tag helpers, asset helpers, form helpers, form builders and many more helpers for padrino}
14
14
  s.email = %q{padrinorb@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -84,7 +84,7 @@ Gem::Specification.new do |s|
84
84
 
85
85
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
86
86
  s.add_runtime_dependency(%q<sinatra>, [">= 0.9.2"])
87
- s.add_runtime_dependency(%q<padrino-core>, ["= 0.8.1"])
87
+ s.add_runtime_dependency(%q<padrino-core>, ["= 0.8.2"])
88
88
  s.add_development_dependency(%q<haml>, [">= 2.2.1"])
89
89
  s.add_development_dependency(%q<shoulda>, [">= 2.10.3"])
90
90
  s.add_development_dependency(%q<mocha>, [">= 0.9.7"])
@@ -92,7 +92,7 @@ Gem::Specification.new do |s|
92
92
  s.add_development_dependency(%q<webrat>, [">= 0.5.1"])
93
93
  else
94
94
  s.add_dependency(%q<sinatra>, [">= 0.9.2"])
95
- s.add_dependency(%q<padrino-core>, ["= 0.8.1"])
95
+ s.add_dependency(%q<padrino-core>, ["= 0.8.2"])
96
96
  s.add_dependency(%q<haml>, [">= 2.2.1"])
97
97
  s.add_dependency(%q<shoulda>, [">= 2.10.3"])
98
98
  s.add_dependency(%q<mocha>, [">= 0.9.7"])
@@ -101,7 +101,7 @@ Gem::Specification.new do |s|
101
101
  end
102
102
  else
103
103
  s.add_dependency(%q<sinatra>, [">= 0.9.2"])
104
- s.add_dependency(%q<padrino-core>, ["= 0.8.1"])
104
+ s.add_dependency(%q<padrino-core>, ["= 0.8.2"])
105
105
  s.add_dependency(%q<haml>, [">= 2.2.1"])
106
106
  s.add_dependency(%q<shoulda>, [">= 2.10.3"])
107
107
  s.add_dependency(%q<mocha>, [">= 0.9.7"])
@@ -16,7 +16,7 @@ class MarkupDemo < Sinatra::Base
16
16
  # show :erb, :index
17
17
  # show :haml, :index
18
18
  def show(kind, template)
19
- eval("#{kind.to_s} #{template.to_sym.inspect}")
19
+ send kind.to_sym, template.to_sym
20
20
  end
21
21
 
22
22
  def captured_content(&block)
@@ -2,7 +2,7 @@
2
2
  <h1>This is content yielded from a content_for</h1>
3
3
  <% end %>
4
4
 
5
- <div class='demo'><%= yield_content :demo %></p>
5
+ <div class='demo'><%= yield_content :demo %></div>
6
6
 
7
7
  <% content_for :demo2 do |fname, lname| %>
8
8
  <h1>This is content yielded with name <%= fname + " " + lname %></h1>
@@ -58,7 +58,7 @@ class TestFormBuilder < Test::Unit::TestCase
58
58
  end
59
59
 
60
60
  should "support changing form builder type" do
61
- form_html = lambda { form_for(@user, '/register', :builder => "AbstractFormBuilder") { |f| f.text_field_block(:name) } }
61
+ form_html = proc { form_for(@user, '/register', :builder => "AbstractFormBuilder") { |f| f.text_field_block(:name) } }
62
62
  assert_raise(NoMethodError) { form_html.call }
63
63
  end
64
64
 
@@ -54,10 +54,10 @@ class TestFormatHelpers < Test::Unit::TestCase
54
54
  assert_equal "Once\nupon\na\ntime", actual_text
55
55
  end
56
56
  should "return proper formatting for default width" do
57
- actual_text = word_wrap(1.upto(50).map.join(" "))
58
- assert_equal 1.upto(30).map.join(" ") + "\n" + 31.upto(50).map.join(" "), actual_text
59
- actual_text = word_wrap(1.upto(50).map.join(" "), 80)
60
- assert_equal 1.upto(30).map.join(" ") + "\n" + 31.upto(50).map.join(" "), actual_text
57
+ actual_text = word_wrap(1.upto(50).to_a.join(" "))
58
+ assert_equal 1.upto(30).to_a.join(" ") + "\n" + 31.upto(50).to_a.join(" "), actual_text
59
+ actual_text = word_wrap(1.upto(50).to_a.join(" "), 80)
60
+ assert_equal 1.upto(30).to_a.join(" ") + "\n" + 31.upto(50).to_a.join(" "), actual_text
61
61
  end
62
62
  end
63
63
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: padrino-helpers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 0.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Padrino Team
@@ -12,7 +12,7 @@ autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
14
 
15
- date: 2010-02-14 00:00:00 +01:00
15
+ date: 2010-02-17 00:00:00 +01:00
16
16
  default_executable:
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
@@ -33,7 +33,7 @@ dependencies:
33
33
  requirements:
34
34
  - - "="
35
35
  - !ruby/object:Gem::Version
36
- version: 0.8.1
36
+ version: 0.8.2
37
37
  version:
38
38
  - !ruby/object:Gem::Dependency
39
39
  name: haml