padrino-helpers 0.9.4 → 0.9.5

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.9.4
1
+ 0.9.5
@@ -19,6 +19,13 @@ module Padrino
19
19
  h text
20
20
  end
21
21
 
22
+ ##
23
+ # Strips all HTML tags from the html
24
+ #
25
+ def strip_tags(html)
26
+ html.gsub(/<\/?[^>]*>/, "") if html
27
+ end
28
+
22
29
  ##
23
30
  # Returns text transformed into HTML using simple formatting rules. Two or more consecutive newlines(\n\n) are considered
24
31
  # as a paragraph and wrapped in <p> tags. One newline (\n) is considered as a linebreak and a <br /> tag is appended.
@@ -58,8 +65,7 @@ module Padrino
58
65
  #
59
66
  # truncate("Once upon a time in a world far far away", :length => 8) => "Once upon..."
60
67
  #
61
- def truncate(text, *args)
62
- options = args.extract_options!
68
+ def truncate(text, options={})
63
69
  options.reverse_merge!(:length => 30, :omission => "...")
64
70
  if text
65
71
  len = options[:length] - options[:omission].length
@@ -6,8 +6,9 @@ module Padrino
6
6
  #
7
7
  # ==== Examples
8
8
  #
9
- # partial 'photo/_item', :object => @photo
10
- # partial 'photo/_item', :collection => @photos
9
+ # partial 'photo/item', :object => @photo
10
+ # partial 'photo/item', :collection => @photos
11
+ # partial 'photo/item', :locals => { :foo => :bar }
11
12
  #
12
13
  def partial(template, options={})
13
14
  options.reverse_merge!(:locals => {}, :layout => false)
@@ -19,16 +20,16 @@ module Padrino
19
20
  if collection = options.delete(:collection)
20
21
  options.delete(:object)
21
22
  counter = 0
22
- collection.collect do |member|
23
+ collection.collect { |member|
23
24
  counter += 1
24
25
  options[:locals].merge!(object_name => member, "#{object_name}_counter".to_sym => counter)
25
- render(template_path, nil, options.merge(:layout => false))
26
- end.join("\n")
26
+ render(template_path, nil, options.dup)
27
+ }.join("\n")
27
28
  else
28
29
  if member = options.delete(:object)
29
30
  options[:locals].merge!(object_name => member)
30
31
  end
31
- render(template_path, nil, options.merge(:layout => false))
32
+ render(template_path, nil, options.dup)
32
33
  end
33
34
  end
34
35
  alias :render_partial :partial
@@ -42,7 +42,7 @@ module Padrino
42
42
  content, open_tag = options.delete(:content), options.delete(:open)
43
43
  content = content.join("\n") if content.respond_to?(:join)
44
44
  identity_tag_attributes.each { |attr| options[attr] = attr.to_s if options[attr] }
45
- html_attrs = options.collect { |a, v| v.nil? ? nil : "#{a}=\"#{v}\"" }.compact.join(" ")
45
+ html_attrs = options.collect { |a, v| v.nil? || v == false ? nil : "#{a}=\"#{v}\"" }.compact.join(" ")
46
46
  base_tag = (html_attrs.present? ? "<#{name} #{html_attrs}" : "<#{name}")
47
47
  base_tag << (open_tag ? ">" : (content ? ">#{content}</#{name}>" : " />"))
48
48
  end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{padrino-helpers}
8
- s.version = "0.9.4"
8
+ s.version = "0.9.5"
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-03-03}
12
+ s.date = %q{2010-03-11}
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,14 +84,14 @@ Gem::Specification.new do |s|
84
84
  s.specification_version = 3
85
85
 
86
86
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
87
- s.add_runtime_dependency(%q<padrino-core>, ["= 0.9.4"])
87
+ s.add_runtime_dependency(%q<padrino-core>, ["= 0.9.5"])
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"])
91
91
  s.add_development_dependency(%q<rack-test>, [">= 0.5.0"])
92
92
  s.add_development_dependency(%q<webrat>, [">= 0.5.1"])
93
93
  else
94
- s.add_dependency(%q<padrino-core>, ["= 0.9.4"])
94
+ s.add_dependency(%q<padrino-core>, ["= 0.9.5"])
95
95
  s.add_dependency(%q<haml>, [">= 2.2.1"])
96
96
  s.add_dependency(%q<shoulda>, [">= 2.10.3"])
97
97
  s.add_dependency(%q<mocha>, [">= 0.9.7"])
@@ -99,7 +99,7 @@ Gem::Specification.new do |s|
99
99
  s.add_dependency(%q<webrat>, [">= 0.5.1"])
100
100
  end
101
101
  else
102
- s.add_dependency(%q<padrino-core>, ["= 0.9.4"])
102
+ s.add_dependency(%q<padrino-core>, ["= 0.9.5"])
103
103
  s.add_dependency(%q<haml>, [">= 2.2.1"])
104
104
  s.add_dependency(%q<shoulda>, [">= 2.10.3"])
105
105
  s.add_dependency(%q<mocha>, [">= 0.9.7"])
@@ -68,6 +68,10 @@ class TestTagHelpers < Test::Unit::TestCase
68
68
  actual_html = input_tag(:checkbox, :checked => true)
69
69
  assert_has_tag('input[type=checkbox]', :checked => 'checked') { actual_html }
70
70
  end
71
+ should "remove checked attribute if false" do
72
+ actual_html = input_tag(:checkbox, :checked => false)
73
+ assert_has_no_tag('input[type=checkbox][checked=false]') { actual_html }
74
+ end
71
75
  should "support disabled attribute by using 'disabled' if true" do
72
76
  actual_html = input_tag(:checkbox, :disabled => true)
73
77
  assert_has_tag('input[type=checkbox]', :disabled => 'disabled') { actual_html }
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 9
8
- - 4
9
- version: 0.9.4
8
+ - 5
9
+ version: 0.9.5
10
10
  platform: ruby
11
11
  authors:
12
12
  - Padrino Team
@@ -17,7 +17,7 @@ autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
19
 
20
- date: 2010-03-03 00:00:00 +01:00
20
+ date: 2010-03-11 00:00:00 +01:00
21
21
  default_executable:
22
22
  dependencies:
23
23
  - !ruby/object:Gem::Dependency
@@ -30,8 +30,8 @@ dependencies:
30
30
  segments:
31
31
  - 0
32
32
  - 9
33
- - 4
34
- version: 0.9.4
33
+ - 5
34
+ version: 0.9.5
35
35
  type: :runtime
36
36
  version_requirements: *id001
37
37
  - !ruby/object:Gem::Dependency