clapton 0.0.7 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -1
- data/app/helpers/clapton/clapton_helper.rb +4 -4
- data/lib/clapton/engine.rb +6 -4
- data/lib/clapton/version.rb +2 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dbc7320b4bfea8d0f2c712ee309bc0c91ffe48b71a12c7508322d4239c1a9d37
|
4
|
+
data.tar.gz: 999f7025335a37a968146c1a684267afa1ffd294c48e9b79f6a34a256b6f07b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9dc054781d095b94f2fcde90b62e8d9b97d349566d63285f4e8a3832e8719ed95fab6a171856bea4c07fc4b85287f7edbd4c89a7976c26ce513f4e54eb9086cd
|
7
|
+
data.tar.gz: 812e6c21b1a09e8b41c8ecab7d2d78d367e156b51c0b9ee56fc7089c72c5ac6a9b1a3fec34c80fc922e81f02b464a2aa714c47f27d9ba011e20fff9910adce56
|
data/README.md
CHANGED
@@ -140,7 +140,12 @@ mount Clapton::Engine => "/clapton"
|
|
140
140
|
### Component rendering
|
141
141
|
|
142
142
|
```html
|
143
|
-
<%= clapton_component_tag(
|
143
|
+
<%= clapton_component_tag(
|
144
|
+
:TaskListComponent,
|
145
|
+
{
|
146
|
+
tasks: @tasks.map { |task| { id: task.id, title: task.title, due: task.due, done: task.done } }
|
147
|
+
}
|
148
|
+
) %>
|
144
149
|
```
|
145
150
|
|
146
151
|
### Generate Component and State
|
@@ -18,12 +18,12 @@ module Clapton
|
|
18
18
|
tag.div(id: "clapton", data: { clapton: datas })
|
19
19
|
end
|
20
20
|
|
21
|
-
def clapton_component_tag(component)
|
22
|
-
state_class = component
|
21
|
+
def clapton_component_tag(component, params)
|
22
|
+
state_class = component.to_s.gsub("Component", "State")
|
23
23
|
if Object.const_defined?(state_class)
|
24
|
-
data = { component: component
|
24
|
+
data = { component: component.to_s, state: Object.const_get(state_class).new(params).to_h }
|
25
25
|
else
|
26
|
-
data = { component: component
|
26
|
+
data = { component: component.to_s, state: {} }
|
27
27
|
end
|
28
28
|
tag.div(class: "clapton-component", data: { clapton: data })
|
29
29
|
end
|
data/lib/clapton/engine.rb
CHANGED
@@ -22,11 +22,13 @@ module Clapton
|
|
22
22
|
|
23
23
|
compile_components
|
24
24
|
|
25
|
-
|
26
|
-
|
27
|
-
|
25
|
+
Rails.env.development? do
|
26
|
+
listener = Listen.to(Rails.root.join("app", "components")) do |modified, added, removed|
|
27
|
+
compile_components
|
28
|
+
end
|
28
29
|
|
29
|
-
|
30
|
+
listener.start
|
31
|
+
end
|
30
32
|
end
|
31
33
|
|
32
34
|
def compile_components
|
data/lib/clapton/version.rb
CHANGED