little_wheels 0.0.14 → 0.0.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/little_wheels.rb +29 -65
- 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: 4032c8ab3d1e59679bd977a166d021f3da97bc3c6e88931fb56abd7a233eceea
|
4
|
+
data.tar.gz: 670ee7c08d9ec651e76892bd6c36fdb9046638c7a0aa572948b8e920dd7224f6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 87033bb602b579ca4c7682820d6cd4d09d4b98638c90f840fad14db9c7ef8d81ca618a114e34539e49f0b0d38c53c77012071ebd3f9893d03b59727a9490d91c
|
7
|
+
data.tar.gz: a7576f978be846cfd4d20fd5cff23a159e7c1d9226b28ed532d1c8073fc91aba76ad783751ad1abb8243e9a4e3903bc64b04688df93c39c7f99b784f050e4ca8
|
data/lib/little_wheels.rb
CHANGED
@@ -1,26 +1,16 @@
|
|
1
1
|
module LittleWheels
|
2
|
-
VERSION = "0.0.
|
2
|
+
VERSION = "0.0.15"
|
3
3
|
|
4
|
-
def self.renderer
|
5
|
-
|
6
|
-
end
|
7
|
-
|
8
|
-
def self.helpers
|
9
|
-
renderer.helpers
|
10
|
-
end
|
4
|
+
def self.renderer = ApplicationController
|
5
|
+
def self.helpers = self.renderer.helpers
|
11
6
|
|
12
7
|
class Buffer
|
13
8
|
def initialize(string)
|
14
9
|
@string = string.html_safe
|
15
10
|
end
|
16
11
|
|
17
|
-
def +(other)
|
18
|
-
|
19
|
-
end
|
20
|
-
|
21
|
-
def to_s
|
22
|
-
@string
|
23
|
-
end
|
12
|
+
def +(other) = self.class.new(@string + other.to_s)
|
13
|
+
def to_s = @string
|
24
14
|
end
|
25
15
|
|
26
16
|
module Component
|
@@ -28,72 +18,46 @@ module LittleWheels
|
|
28
18
|
def [](*a, **o, &b) = new(*a, **o, &b)
|
29
19
|
end
|
30
20
|
|
31
|
-
def self.included(base)
|
32
|
-
base.extend(ClassMethods)
|
33
|
-
end
|
21
|
+
def self.included(base) = base.extend(ClassMethods)
|
34
22
|
|
35
|
-
def t(template, **locals)
|
36
|
-
renderer.render(inline: template, locals:)
|
37
|
-
end
|
23
|
+
def t(template, **locals) = renderer.render(inline: template, locals:)
|
38
24
|
|
39
|
-
def t!(template, **locals)
|
40
|
-
renderer.render(template, locals:, layout: nil)
|
41
|
-
end
|
25
|
+
def t!(template, **locals) = renderer.render(template, locals:, layout: nil)
|
42
26
|
|
43
|
-
def x
|
44
|
-
helpers.tag
|
45
|
-
end
|
27
|
+
def x = helpers.tag
|
46
28
|
|
47
|
-
def o(&block)
|
48
|
-
block.binding.receiver.capture(&block)
|
49
|
-
end
|
29
|
+
def o(&block) = block.binding.receiver.capture(&block)
|
50
30
|
|
51
|
-
def +(other)
|
52
|
-
Buffer.new(to_s + other.to_s)
|
53
|
-
end
|
31
|
+
def +(other) = Buffer.new(to_s + other.to_s)
|
54
32
|
|
55
|
-
def
|
56
|
-
to_html
|
57
|
-
end
|
33
|
+
def accepts_slot(block) = @_slot = block
|
58
34
|
|
59
|
-
def
|
60
|
-
helpers.capture do
|
61
|
-
if self.class.const_defined?(:TEMPLATE)
|
62
|
-
t(self.class.const_get(:TEMPLATE), c: self, x: self.x )
|
63
|
-
else
|
64
|
-
t!(default_template_name, c: self, x: self.x )
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
35
|
+
def capture(&block) = block.call.to_s.html_safe
|
68
36
|
|
69
|
-
def
|
70
|
-
@_slot = block
|
71
|
-
end
|
37
|
+
def default_template_name = "shared/#{self.class.name.underscore}"
|
72
38
|
|
73
|
-
def
|
74
|
-
context = @_slot.binding.receiver
|
39
|
+
def helpers = LittleWheels.helpers
|
75
40
|
|
76
|
-
|
77
|
-
end
|
41
|
+
def renderer = LittleWheels.renderer
|
78
42
|
|
79
|
-
def
|
80
|
-
LittleWheels.renderer
|
81
|
-
end
|
43
|
+
def render_in(context) = context.render(:inline => to_html)
|
82
44
|
|
83
|
-
def
|
84
|
-
LittleWheels.helpers
|
85
|
-
end
|
45
|
+
def to_s = to_html
|
86
46
|
|
87
|
-
def
|
88
|
-
|
89
|
-
end
|
47
|
+
def slot
|
48
|
+
context = @_slot.binding.receiver
|
90
49
|
|
91
|
-
|
92
|
-
block.call.to_s.html_safe
|
50
|
+
context.capture { @_slot.call.to_s }
|
93
51
|
end
|
94
52
|
|
95
|
-
def
|
96
|
-
|
53
|
+
def to_html
|
54
|
+
helpers.capture do
|
55
|
+
if self.class.const_defined?(:TEMPLATE)
|
56
|
+
t(self.class.const_get(:TEMPLATE), c: self, x: self.x )
|
57
|
+
else
|
58
|
+
t!(default_template_name, c: self, x: self.x )
|
59
|
+
end
|
60
|
+
end
|
97
61
|
end
|
98
62
|
end
|
99
63
|
end
|