angular_sprinkles 0.3.2 → 0.3.3

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: 2c84a9327601bb19ef5f599a920f2101ed7abf97
4
- data.tar.gz: d3ade5584370e4faf96bec0bbb3e707f6d9cc2b5
3
+ metadata.gz: a105dde16e07e76ef724f5116459cb4c5bba23c0
4
+ data.tar.gz: c8180b0c5efe0fbcdb840aa42ff68c9879c40bea
5
5
  SHA512:
6
- metadata.gz: c8b0fac59ea91aa296c954a8031ce37773677755cb5764aa4d528c6a69f6c6caa540efa5ab4caba8c1fa1c03248427b5659a975d96b5f076ba674f776686475b
7
- data.tar.gz: 73ac64dbb88d7e755ee4fbf3f15a4c816dbd0b83fbc346c2dc58eb799a8975f834f51b384d29138bc3e5651b5b1de1d871aeb2d1f8b59894334452092998b2f0
6
+ metadata.gz: be8a85c9a7e8788fffa62e495823762ce9bfa1d43562024225a9761f87119d62713cb69786828ed1c7823652b438a7a6a126180fa4081d225ef5be90ee5df66b
7
+ data.tar.gz: 83661238f57d6843a6e73101aac604ece64cb1673fb3d793a20db49ee92a647a612838eacc250a182a5adbc33422135bbbea4b2496d350cca771e229461ccd9c
data/README.md CHANGED
@@ -42,9 +42,10 @@ Include and `angular_sprinkles` into your `application.js`.
42
42
 
43
43
  - [Two-way binding](#two-way-binding)
44
44
  - [Directives](#directives)
45
- - [Controllers and Isolate Scopes](#controllers-and-isolate-scopes)
45
+ - [Controllers and isolate scopes](#controllers-and-isolate-scopes)
46
46
  - [Inlining function calls](#inlining-function-calls)
47
47
  - [Form helpers](#form-helpers)
48
+ - [Forcing ruby wrappers for variable names](#forcing-ruby-wrappers-for-variable-names)
48
49
 
49
50
  ### Two-way binding
50
51
 
@@ -104,7 +105,7 @@ sprinkles.directive('someDirective', function () {
104
105
  <% end %>
105
106
  ```
106
107
 
107
- ### Controllers and Isolate Scopes
108
+ ### Controllers and isolate scopes
108
109
 
109
110
  If you would rather skip the directive and just create a controller, there is the `ctrl` helper.
110
111
 
@@ -147,7 +148,7 @@ sprinkles.service('alertMe', function () {
147
148
  });
148
149
  </script>
149
150
 
150
- <button ng-click="<%= ng_service(:alert_me, "world") %>">Click me!</button>
151
+ <button ng-click="<%= ng_service(:alertMe, "world") %>">Click me!</button>
151
152
  ```
152
153
 
153
154
  ### Form helpers
@@ -183,6 +184,29 @@ sprinkles.service('userFormHandler', function () {
183
184
  <% end %>
184
185
  ```
185
186
 
187
+ ### Forcing ruby wrappers for variable names
188
+
189
+ It is sometimes useful to be able to wrap a variable name into a ruby helper. The following example illustrates how it may be useful to
190
+ wrap the result of a `ng-repeat` so that it can be combined with the other helpers in this library.
191
+
192
+ ```erb
193
+ <div ng-repeat="user in <%= @users.bind %>">
194
+ <%= ng_wrap('user') do |user| %>
195
+ {{ <%= user.bind %> }}
196
+ <button ng-click="<%= ng_service(:alertMe, user.bind(:name)) %>">Alert me!</button>
197
+ <% end %>
198
+ </div>
199
+ ```
200
+
201
+ `ng_wrap` is also capable of accepting multiple parameters.
202
+
203
+ ```erb
204
+ <%= ng_wrap('user', 'user.name') do |user, name| %>
205
+ {{ <%= user.bind %> }}
206
+ <button ng-click="<%= ng_service(:alertMe, name.bind) %>">Alert me!</button>
207
+ <% end %>
208
+ ```
209
+
186
210
  ### I want more!
187
211
 
188
212
  Also see the [demo application](https://github.com/BrewhouseTeam/angular_sprinkles_example) for more examples.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.2
1
+ 0.3.3
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: angular_sprinkles 0.3.2 ruby lib
5
+ # stub: angular_sprinkles 0.3.3 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "angular_sprinkles"
9
- s.version = "0.3.2"
9
+ s.version = "0.3.3"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib"]
13
13
  s.authors = ["Gabe Scholz"]
14
- s.date = "2014-10-24"
14
+ s.date = "2014-10-29"
15
15
  s.description = "Add a few sprinkles of AngularJS to your Rails App"
16
16
  s.email = "gabe@brewhouse.io"
17
17
  s.extra_rdoc_files = [
@@ -1,15 +1,17 @@
1
1
  module AngularSprinkles
2
2
  module Helpers
3
3
  module WrapHelper
4
- def ng_wrap(name, &block)
5
- scope = Element::Scope.new({
6
- base: name,
7
- object_wrapper: ObjectKeyWrapper,
8
- bind_json_wrapper: JavaScript::NoOp,
9
- call_json_wrapper: JavaScript::BindService
10
- })
4
+ def ng_wrap(*names, &block)
5
+ scopes = names.map do |name|
6
+ Element::Scope.new({
7
+ base: name,
8
+ object_wrapper: ObjectKeyWrapper,
9
+ bind_json_wrapper: JavaScript::NoOp,
10
+ call_json_wrapper: JavaScript::BindService
11
+ })
12
+ end
11
13
 
12
- capture(scope, &block)
14
+ capture(*scopes, &block)
13
15
  end
14
16
  end
15
17
  end
@@ -3,8 +3,8 @@
3
3
  <div id="bind-div" ng-bind="<%= ng_bind(:hello, :world) %>"></div>
4
4
 
5
5
  <%= ng_directive(:bigHelloWorld, html: { id: "directive-div" }) do |ctrl| %>
6
- <div id="directive-ctrl-bind" ng-bind="<%= ctrl.bind(:attribute) %>"></div>
7
- <div id="directive-ctrl-call" ng-bind="<%= ctrl.call(:func, 'func result') %>"></div>
6
+ <div id="directive-ctrl-bind-div" ng-bind="<%= ctrl.bind(:attribute) %>"></div>
7
+ <div id="directive-ctrl-call-div" ng-bind="<%= ctrl.call(:func, 'func result') %>"></div>
8
8
 
9
9
  <%= ng_directive(:nested_directive, name: @model.bind(:name), html: { tag: 'h1' }) %>
10
10
  <% end %>
@@ -18,12 +18,20 @@
18
18
  <div id="isolate-div" ng-bind="<%= ctrl.bind(:someValue) %>"></div>
19
19
  <% end %>
20
20
 
21
- <div id="model-bind">
21
+ <div id="model-bind-div">
22
22
  <label for="input">Input</label>
23
23
  <input id="input" name="input" type="text" ng-model="<%= @model.bind(:name) %>" />
24
24
  </div>
25
25
 
26
- <div id="bind-bind">
26
+ <%= ng_isolate do %>
27
+ <%= ng_wrap('a', 'b') do |a, b| %>
28
+ {{ <%= a.bind %> = 5 }}
29
+ {{ <%= b.bind %> = 6 }}
30
+ <div id="wrap-div">{{ <%= a.bind %> + <%= b.bind %> }}</div>
31
+ <% end %>
32
+ <% end %>
33
+
34
+ <div id="bind-bind-div">
27
35
  <label for="bind">Bind</label>
28
36
  <input id="bind" name="bind" type="text" ng-model="<%= ng_bind(:hello, :world) %>" />
29
37
  </div>
@@ -26,9 +26,10 @@ feature "javascript_bindings", js: true do
26
26
  expect(find("#bind-div")).to have_content(new_name)
27
27
 
28
28
  # directive controller results
29
- expect(find("#directive-ctrl-bind")).to have_content("bigHelloWorldCtrlAttribute")
30
- expect(find("#directive-ctrl-call")).to have_content('func result')
29
+ expect(find("#directive-ctrl-bind-div")).to have_content("bigHelloWorldCtrlAttribute")
30
+ expect(find("#directive-ctrl-call-div")).to have_content('func result')
31
31
  expect(find("#ctrl-div")).to have_content(42)
32
32
  expect(find("#isolate-div")).to have_content(42)
33
+ expect(find("#wrap-div")).to have_content(11)
33
34
  end
34
35
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: angular_sprinkles
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gabe Scholz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-24 00:00:00.000000000 Z
11
+ date: 2014-10-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails