coffee-cup 0.0.1 → 0.0.2
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/README.md +18 -13
- data/app/assets/javascripts/coffee_cup/views/base.coffee +4 -3
- metadata +8 -8
data/README.md
CHANGED
@@ -31,6 +31,15 @@ In your Gemfile:
|
|
31
31
|
gem 'coffee-cup'
|
32
32
|
```
|
33
33
|
|
34
|
+
In your javascript manifest
|
35
|
+
|
36
|
+
```javascript
|
37
|
+
// app/assets/javascripts/application.js
|
38
|
+
//= require jquery
|
39
|
+
//= require jquery_ujs
|
40
|
+
//= require coffee_cup
|
41
|
+
```
|
42
|
+
|
34
43
|
Coffee Cup rely on a data attribute inside the body tag to indicate the current controller and action.
|
35
44
|
It is required to add to your body tag the following code :
|
36
45
|
|
@@ -38,7 +47,6 @@ It is required to add to your body tag the following code :
|
|
38
47
|
content_tag(:body, "data-coffee-cup" => CoffeeCup.body_data(request)) do
|
39
48
|
# Layout
|
40
49
|
end
|
41
|
-
|
42
50
|
```
|
43
51
|
|
44
52
|
Usage
|
@@ -53,18 +61,15 @@ You must first create the following directories :
|
|
53
61
|
|
54
62
|
```
|
55
63
|
# In app/assets/javascripts/
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
64
|
+
app
|
65
|
+
|-- helpers
|
66
|
+
|-- application_helpers.coffee
|
67
|
+
|-- views
|
61
68
|
```
|
62
69
|
|
63
70
|
### Helpers
|
64
|
-
|
65
|
-
In the application_helpers.coffee
|
66
|
-
|
67
71
|
```coffeescript
|
72
|
+
# app/assets/javascripts/app/helpers/application_helpers.coffee
|
68
73
|
@module "ApplicationHelper", ->
|
69
74
|
@initialize = ->
|
70
75
|
```
|
@@ -78,7 +83,7 @@ Inside the views directory, you will place the code for each view. For example,
|
|
78
83
|
for the users_controller#show, you will create the following file.
|
79
84
|
|
80
85
|
```coffeescript
|
81
|
-
#
|
86
|
+
# app/assets/javascripts/app/views/users/show.coffee
|
82
87
|
@view "Users.Show",
|
83
88
|
constructor: -> # Insert your code for the Users Show action.
|
84
89
|
```
|
@@ -94,19 +99,19 @@ For example, if you need the same code inside the Users New and Edit, let's say
|
|
94
99
|
the following :
|
95
100
|
|
96
101
|
```coffeescript
|
97
|
-
#
|
102
|
+
# app/assets/javascripts/app/views/users/new.coffee
|
98
103
|
@view "Users.New",
|
99
104
|
constructor: -> @render 'users/form'
|
100
105
|
```
|
101
106
|
|
102
107
|
```coffeescript
|
103
|
-
#
|
108
|
+
# app/assets/javascripts/app/views/users/edit.coffee
|
104
109
|
@view "Users.Edit",
|
105
110
|
constructor: -> @render 'users/form'
|
106
111
|
```
|
107
112
|
|
108
113
|
```coffeescript
|
109
|
-
#
|
114
|
+
# app/assets/javascripts/app/views/users/_form.coffee
|
110
115
|
@view "Users.Form",
|
111
116
|
constructor: -> # This code will be shared between the New and Edit actions.
|
112
117
|
```
|
@@ -13,15 +13,16 @@ class @ActionView
|
|
13
13
|
loadPartial: (url, callback, rootTag = '') ->
|
14
14
|
if url.indexOf('?') > 0 then url += '&layout=none' else url += '?layout=none'
|
15
15
|
|
16
|
-
$.get(url, (data) => @receivePartial(data, callback, rootTag))
|
16
|
+
$.get(url, (data) => @receivePartial(data, this, callback, rootTag))
|
17
17
|
|
18
18
|
|
19
19
|
locale: () -> $('meta[name="content-language"]').attr('content')
|
20
20
|
|
21
21
|
|
22
|
-
receivePartial: (data, callback, rootTag) ->
|
22
|
+
receivePartial: (data, caller, callback, rootTag) ->
|
23
23
|
partial = $('<div>' + data + '</div>').find(rootTag).html()
|
24
24
|
|
25
|
-
callback
|
25
|
+
caller[callback](partial)
|
26
|
+
|
26
27
|
|
27
28
|
render: (path) -> CoffeeCup.renderView CoffeeCup.camelize(path)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: coffee-cup
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-09-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
16
|
-
requirement: &
|
16
|
+
requirement: &2152408220 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 0.8.7
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2152408220
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rspec
|
27
|
-
requirement: &
|
27
|
+
requirement: &2160226000 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '2.0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *2160226000
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: metrical
|
38
|
-
requirement: &
|
38
|
+
requirement: &2160220560 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: 0.1.0
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *2160220560
|
47
47
|
description: Coffee Cup set the foundations of a Rails like structure for your all
|
48
48
|
your CoffeeScript code.
|
49
49
|
email:
|