de_rjs 0.4.1 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0cb5070d80456eed3d309af1d97f7cc475017dfa
4
- data.tar.gz: bff3f65ca263d976f3683c7ee7c211cb801cca5a
3
+ metadata.gz: 574697ee1e28df30923b0c2ccac6181b257f2485
4
+ data.tar.gz: e7f6b8cfba7c0bac2150ce265b95b3a4be4c3f43
5
5
  SHA512:
6
- metadata.gz: 9e945e642672557ae3dec919b6be8817c0058a9e9f5e8b3ed35e11395bfea6d72971bc564335227fd8291dce10b4df025d45893efc8df71836699bd4fbc762d9
7
- data.tar.gz: cb30b874cc9324e3c8223031755364f50a4e2c41fd2b75ec4c6e08a70e8500f6ad18d37b32f8323f72d5b6db31e96ff12a8759ee05e257b604f24dc53dbee2ee
6
+ metadata.gz: c49c29aa19cc77d5a84481fff423ca5a44ee30e426ee55f4ab04fdf6ede76aba4241f8d4bb24cbbc6fb02ba4db15f8d757944018bca01d64af27fbd228247dd2
7
+ data.tar.gz: 105cd7cb54f3081fa85e22f35fcfc130abf1c0e5cc9ce39dde749f21a59cfafa3e3fe8e4c91141c9306816aeace4b4bcbd79052c04d121a4c109ad23459b7d15
@@ -96,10 +96,17 @@ module DeRjs
96
96
  array[0..1] == [nil, :dom_id] #&& array.size == 3
97
97
  end
98
98
 
99
+ # if Hash, render
100
+ # else assume it's a string
99
101
  def rewrite_options_for_render(arg_nodes)
100
102
  return if arg_nodes.size == 1 && arg_nodes.first.type == :str
101
- insert_before arg_nodes.first.loc.expression, "%q{<%= escape_javascript(render("
102
- insert_after arg_nodes.last.loc.expression, ")) %>}"
103
+ if arg_nodes.first.type == :hash
104
+ insert_before arg_nodes.first.loc.expression, "%q{<%= escape_javascript(render("
105
+ insert_after arg_nodes.last.loc.expression, ")) %>}"
106
+ else
107
+ insert_before arg_nodes.first.loc.expression, "%q{<%= escape_javascript("
108
+ insert_after arg_nodes.last.loc.expression, ") %>}"
109
+ end
103
110
  end
104
111
 
105
112
  def rewrite_url_for(url_arg)
@@ -41,12 +41,12 @@ class DeRjsTest < DeRjsBaseTest
41
41
  end
42
42
 
43
43
  def test_replace_html_with_string
44
- assert_equal 'jQuery("#element").html("\\u003cp\\u003eThis is a test\\u003c/p\\u003e");',
44
+ assert_equal 'jQuery("#element").html("<p>This is a test</p>");',
45
45
  generate_js(%Q{ page.replace_html('element', '<p>This is a test</p>') })
46
46
  end
47
47
 
48
48
  def test_replace_element_with_string
49
- assert_equal 'jQuery("#element").replaceWith("\\u003cdiv id=\"element\"\\u003e\\u003cp\\u003eThis is a test\\u003c/p\\u003e\\u003c/div\\u003e");',
49
+ assert_equal 'jQuery("#element").replaceWith("<div id=\"element\"><p>This is a test</p></div>");',
50
50
  generate_js(%Q{ page.replace('element', '<div id="element"><p>This is a test</p></div>') })
51
51
  end
52
52
 
@@ -55,11 +55,21 @@ class DeRjsTest < DeRjsBaseTest
55
55
  generate_js(%Q{ page.insert_html(:top, 'element', :partial => "post", :locals => {:ab => "cd"}) })
56
56
  end
57
57
 
58
+ def test_insert_html_with_var
59
+ assert_equal 'jQuery("#element").prepend("<%= escape_javascript(@var) %>");',
60
+ generate_js(%Q{ page.insert_html(:top, 'element', @var) })
61
+ end
62
+
58
63
  def test_replace_html_with_hash
59
64
  assert_equal 'jQuery("#element").html("<%= escape_javascript(render(:partial => "post", :locals => {:ab => "cd"})) %>");',
60
65
  generate_js(%Q{ page.replace_html('element', :partial => "post", :locals => {:ab => "cd"}) })
61
66
  end
62
67
 
68
+ def test_replace_html_with_var
69
+ assert_equal 'jQuery("#element").html("<%= escape_javascript(@var) %>");',
70
+ generate_js(%Q{ page.replace_html('element', @var) })
71
+ end
72
+
63
73
  def test_replace_element_with_hash
64
74
  assert_equal 'jQuery("#element").replaceWith("<%= escape_javascript(render(:partial => "post", :locals => {:ab => "cd"})) %>");',
65
75
  generate_js(%Q{ page.replace('element', :partial => "post", :locals => {:ab => "cd"}) })
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: de_rjs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thong Kuah
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-03 00:00:00.000000000 Z
11
+ date: 2017-08-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -102,7 +102,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
102
102
  version: '0'
103
103
  requirements: []
104
104
  rubyforge_project:
105
- rubygems_version: 2.5.2
105
+ rubygems_version: 2.6.13
106
106
  signing_key:
107
107
  specification_version: 4
108
108
  summary: de-RJS your application