angular_sprinkles 0.2.5 → 0.2.6

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: af0082e8d01fae6f825eee0706dbe3f167f37e2b
4
- data.tar.gz: f7c17e63a24e05ab47dfe98a9383bfde59afe6dc
3
+ metadata.gz: 29780781f6f1a44151e53bde825254e42340bb5c
4
+ data.tar.gz: 0a5cbd173719b988e276f77c121a28c8fcfd60e2
5
5
  SHA512:
6
- metadata.gz: d14174b5411a86e594999018de7031e87d018c9987b16891866d32d1fa61c8937aadac274d556217140af4f87a8825e3727b940a1a5fb74b7f7c6cac50265bad
7
- data.tar.gz: a34110ecbe68be5321eb7c3f8b8b44e4f7361f1c3df6330e8357ba8180ebaf609fe838ce72707c8dccd958b1efc4d48500cc3433c84d098ac20adb721806ba23
6
+ metadata.gz: 56b128b9d8d4693ff7b07ab7df4f410809d1bdef547b2cf6118ddd426a5e66d720eb40e13778dd5d39594ddceda0d2be07080cb446c4bef37d31e7bbc2c7e261
7
+ data.tar.gz: 60660791c8f2f2524bbdb922bc9392be542c7d81ff653bcb81cc63586581d4daf0ed25e1452d999b7255f75f579c5755c9ee48c71fea0787cba43a249eba6c3d
data/README.md CHANGED
@@ -10,8 +10,43 @@ Angular Sprinkles is a gem for writing Rails-flavored AngularJS.
10
10
  - __Rails as it was intended to be written:__ Angular's two-way data binding, directives, and function calls are all done in the view via helper methods, giving you just a sprinkle of JavaScript.
11
11
  - __A cleaner approach to JavaScript:__ Sprinkles allows you to continue to write Rails applications as you always have without all of the nasty jQuery spaghetti.
12
12
 
13
+
14
+ ## Setup
15
+
16
+ Add `angular_sprinkles` to your `Gemfile`.
17
+
18
+ ```ruby
19
+ gem 'angularjs-rails'
20
+ gem 'angular_sprinkles'
21
+ ```
22
+
23
+ Add `yield :sprinkles` to the bottom of your body tag.
24
+
25
+ ```erb
26
+ <body>
27
+
28
+ <%= yield %>
29
+
30
+ <%= yield :sprinkles %>
31
+ </body>
32
+ ```
33
+
34
+ Include and `angular_sprinkles` into your `application.js`.
35
+
36
+ ```js
37
+ //= require angular_sprinkles
38
+ //= require_tree .
39
+ ```
40
+
13
41
  ## Examples
14
42
 
43
+ - [Two-way binding](#two-way-binding)
44
+ - [Directives](#directives)
45
+ - [Inlining function calls](#inlining-function-calls)
46
+ - [Form helpers](#form-helpers)
47
+
48
+ ### Two-way binding
49
+
15
50
  Two-way binding works right out of the box with Sprinkles. Just wrap your objects with the `bindable` helper.
16
51
 
17
52
  ```ruby
@@ -28,6 +63,8 @@ end
28
63
  <input type="text" ng-model="<%= @user.bind(:name) %>" />
29
64
  ```
30
65
 
66
+ ### Directives
67
+
31
68
  Use custom directives with the `directive` helper.
32
69
 
33
70
  ```erb
@@ -42,6 +79,8 @@ sprinkles.directive('blink', function () {
42
79
  <% end %>
43
80
  ```
44
81
 
82
+ ### Inlining function calls
83
+
45
84
  Call services directly from the view with the `service` helper.
46
85
 
47
86
  ```erb
@@ -56,34 +95,42 @@ sprinkles.service('alertMe', function () {
56
95
  <button ng-click="<%= service(:alert_me, "world") %>">Click me!</button>
57
96
  ```
58
97
 
59
- Also see the [demo application](https://github.com/BrewhouseTeam/angular_sprinkles_example) for more examples.
98
+ ### Form helpers
60
99
 
61
- ## Setup
100
+ Sprinkles comes with helpers for automatically creating bindings with your form elements. Almost all of the usual form helpers are available with the `bind_*` prefix. (See [issue #4](https://github.com/BrewhouseTeam/angular_sprinkles/issues/4) for a list of helpers that are not currently supported).
62
101
 
63
- Add `angular_sprinkles` to your `Gemfile`.
102
+ ```erb
103
+ <%= form_for @user do |f| %>
104
+ <%= f.bind_text_field :name %>
105
+ <%= f.bind_select :age, (1..99) %>
106
+ <% end %>
64
107
 
65
- ```ruby
66
- gem 'angularjs-rails'
67
- gem 'angular_sprinkles'
108
+ <div>
109
+ <%=# This value is automatically bound to the input of the form %>
110
+ {{ <%= @user.bind(:name) %> }}
111
+ </div>
68
112
  ```
69
113
 
70
- Add `yield :sprinkles` to the bottom of your body tag.
114
+ Additionally, the `bind_form_for` helper will prevent the form from being submitted and bind the form submission to an Angular service.
71
115
 
72
116
  ```erb
73
- <body>
74
-
75
- <%= yield %>
117
+ <script>
118
+ sprinkles.service('userFormHandler', function () {
119
+ // receives the object and the AngularJS representation of the form
120
+ return function (user, form) {
121
+ // do something with the result
122
+ };
123
+ });
124
+ </script>
76
125
 
77
- <%= yield :sprinkles %>
78
- </body>
126
+ <%= bind_form_for @user, :user_form_handler do |f| %>
127
+ <%= f.bind_text_field :name %>
128
+ <% end %>
79
129
  ```
80
130
 
81
- Include and `angular_sprinkles` into your `application.js`.
131
+ ### I want more!
82
132
 
83
- ```js
84
- //= require angular_sprinkles
85
- //= require_tree .
86
- ```
133
+ Also see the [demo application](https://github.com/BrewhouseTeam/angular_sprinkles_example) for more examples.
87
134
 
88
135
  ## Copyright
89
136
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.5
1
+ 0.2.6
@@ -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.2.5 ruby lib
5
+ # stub: angular_sprinkles 0.2.6 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "angular_sprinkles"
9
- s.version = "0.2.5"
9
+ s.version = "0.2.6"
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-13"
14
+ s.date = "2014-10-15"
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 = [
@@ -10,10 +10,7 @@ module AngularSprinkles
10
10
  # is the name of a service. Two arguments are passed to the service:
11
11
  # the object and the Angular representation of the form.
12
12
  def bind_form_for(record, submit_callback, options = {}, &block)
13
- form_name = ObjectKeyWrapper.new(
14
- @_sprinkles.key_generator.call(AngularSprinkles::Form.new),
15
- JavaScript::NoOp
16
- )
13
+ form_name = ObjectKeyWrapper.new('form', JavaScript::NoOp)
17
14
 
18
15
  html_options = {
19
16
  'name' => form_name,
@@ -26,13 +23,4 @@ module AngularSprinkles
26
23
  end
27
24
  end
28
25
  end
29
-
30
- private
31
-
32
- ##
33
- # AngularSprinkles::Form
34
- #
35
- # An empty placeholder class to be used by KeyGenerator when adding
36
- # the form_name attribute in AngularSprinkles::Helpers::BindFormForHelper
37
- class Form; end
38
26
  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.2.5
4
+ version: 0.2.6
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-13 00:00:00.000000000 Z
11
+ date: 2014-10-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails