weppos-helperful 0.3.0 → 0.3.1
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/CHANGELOG.rdoc +5 -0
- data/helperful.gemspec +2 -2
- data/lib/helperful/javascript_helper.rb +1 -1
- data/lib/helperful/version.rb +1 -1
- data/test/javascript_helper_test.rb +45 -7
- metadata +2 -2
data/CHANGELOG.rdoc
CHANGED
@@ -1,6 +1,11 @@
|
|
1
1
|
= Changelog
|
2
2
|
|
3
3
|
|
4
|
+
== Release 0.3.1
|
5
|
+
|
6
|
+
* FIXED: #javascript_content_for doesn't properly concat output when called with block (closes #183).
|
7
|
+
|
8
|
+
|
4
9
|
== Release 0.3.0
|
5
10
|
|
6
11
|
* ADDED: Added #javascript_content_for helper. #javascript_content_for combines the features of #content_for and #javascript_tag (closes #149).
|
data/helperful.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{helperful}
|
5
|
-
s.version = "0.3.
|
5
|
+
s.version = "0.3.1"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Simone Carletti"]
|
9
|
-
s.date = %q{2009-03-
|
9
|
+
s.date = %q{2009-03-24}
|
10
10
|
s.description = %q{Helperful aims to be a collection of useful and reusable Rails helpers.}
|
11
11
|
s.email = %q{weppos@weppos.net}
|
12
12
|
s.extra_rdoc_files = ["CHANGELOG.rdoc", "lib/helperful/affiliations_helper.rb", "lib/helperful/content_helper.rb", "lib/helperful/deprecations.rb", "lib/helperful/javascript_helper.rb", "lib/helperful/title_helper.rb", "lib/helperful/version.rb", "lib/helperful.rb", "LICENSE.rdoc", "README.rdoc"]
|
@@ -74,7 +74,7 @@ module Helperful
|
|
74
74
|
#
|
75
75
|
def javascript_content_for(name, content_or_options_with_block = nil, html_options = {}, &block)
|
76
76
|
if block_given?
|
77
|
-
content_for(name, javascript_tag(
|
77
|
+
content_for(name, javascript_tag(capture(&block), content_or_options_with_block || {}))
|
78
78
|
else
|
79
79
|
content_for(name, javascript_tag(content_or_options_with_block, html_options))
|
80
80
|
end
|
data/lib/helperful/version.rb
CHANGED
@@ -16,6 +16,21 @@ class JavascriptHelperTest < ActionView::TestCase
|
|
16
16
|
@content_for_name
|
17
17
|
end
|
18
18
|
|
19
|
+
def test_javascript_content_for_with_block_in_erb
|
20
|
+
__in_erb_template = ''
|
21
|
+
javascript_content_for(:name) { concat "alert('hello')" }
|
22
|
+
|
23
|
+
assert_dom_equal "<script type=\"text/javascript\">\n//<![CDATA[\nalert('hello')\n//]]>\n</script>",
|
24
|
+
@content_for_name
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_javascript_content_for_with_block_out_of_erb
|
28
|
+
javascript_content_for(:name) { "alert('hello')" }
|
29
|
+
|
30
|
+
assert_dom_equal "<script type=\"text/javascript\">\n//<![CDATA[\nalert('hello')\n//]]>\n</script>",
|
31
|
+
@content_for_name
|
32
|
+
end
|
33
|
+
|
19
34
|
def test_javascript_content_for_with_options
|
20
35
|
javascript_content_for(:name, "alert('hello')", :id => "the_js_tag")
|
21
36
|
|
@@ -23,18 +38,17 @@ class JavascriptHelperTest < ActionView::TestCase
|
|
23
38
|
@content_for_name
|
24
39
|
end
|
25
40
|
|
26
|
-
def
|
41
|
+
def test_javascript_content_for_with_options_and_block_in_erb
|
27
42
|
__in_erb_template = ''
|
28
|
-
javascript_content_for(:name) { concat "alert('hello')" }
|
43
|
+
javascript_content_for(:name, :id => "the_js_tag") { concat "alert('hello')" }
|
29
44
|
|
30
|
-
assert_dom_equal "<script type=\"text/javascript\">\n//<![CDATA[\nalert('hello')\n//]]>\n</script>",
|
45
|
+
assert_dom_equal "<script id=\"the_js_tag\" type=\"text/javascript\">\n//<![CDATA[\nalert('hello')\n//]]>\n</script>",
|
31
46
|
@content_for_name
|
32
47
|
end
|
33
48
|
|
34
|
-
def
|
35
|
-
|
36
|
-
|
37
|
-
|
49
|
+
def test_javascript_content_for_with_options_and_block_out_of_erb
|
50
|
+
javascript_content_for(:name, :id => "the_js_tag") { "alert('hello')" }
|
51
|
+
|
38
52
|
assert_dom_equal "<script id=\"the_js_tag\" type=\"text/javascript\">\n//<![CDATA[\nalert('hello')\n//]]>\n</script>",
|
39
53
|
@content_for_name
|
40
54
|
end
|
@@ -50,4 +64,28 @@ class JavascriptHelperTest < ActionView::TestCase
|
|
50
64
|
@content_for_name
|
51
65
|
end
|
52
66
|
|
67
|
+
def test_javascript_content_for_with_subsequent_calls_and_block_in_erb
|
68
|
+
__in_erb_template = ''
|
69
|
+
|
70
|
+
javascript_content_for(:name) { concat "alert('hello')" }
|
71
|
+
javascript_content_for(:name) { concat "alert('world')" }
|
72
|
+
|
73
|
+
expected = "<script type=\"text/javascript\">\n//<![CDATA[\nalert('hello')\n//]]>\n</script>"
|
74
|
+
expected += "<script type=\"text/javascript\">\n//<![CDATA[\nalert('world')\n//]]>\n</script>"
|
75
|
+
|
76
|
+
assert_dom_equal expected,
|
77
|
+
@content_for_name
|
78
|
+
end
|
79
|
+
|
80
|
+
def test_javascript_content_for_with_subsequent_calls_and_block_out_of_erb
|
81
|
+
javascript_content_for(:name) { "alert('hello')" }
|
82
|
+
javascript_content_for(:name) { "alert('world')" }
|
83
|
+
|
84
|
+
expected = "<script type=\"text/javascript\">\n//<![CDATA[\nalert('hello')\n//]]>\n</script>"
|
85
|
+
expected += "<script type=\"text/javascript\">\n//<![CDATA[\nalert('world')\n//]]>\n</script>"
|
86
|
+
|
87
|
+
assert_dom_equal expected,
|
88
|
+
@content_for_name
|
89
|
+
end
|
90
|
+
|
53
91
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: weppos-helperful
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Simone Carletti
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-03-
|
12
|
+
date: 2009-03-24 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|