coffee-cup 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
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
- app
57
- |--- helpers
58
- |--- application_helpers.coffee
59
- |--- views
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
- # /app/assets/javascripts/app/views/users/show.coffee
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
- # /app/assets/javascripts/app/views/users/new.coffee
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
- # /app/assets/javascripts/app/views/users/edit.coffee
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
- # /app/assets/javascripts/app/views/users/_form.coffee
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 partial
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.1
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-04-30 00:00:00.000000000 Z
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: &2151892760 !ruby/object:Gem::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: *2151892760
24
+ version_requirements: *2152408220
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rspec
27
- requirement: &2151891960 !ruby/object:Gem::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: *2151891960
35
+ version_requirements: *2160226000
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: metrical
38
- requirement: &2151890920 !ruby/object:Gem::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: *2151890920
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: