little_wheels 0.0.13 → 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 +33 -61
- metadata +3 -3
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,91 +1,63 @@
|
|
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
|
27
|
-
|
28
|
-
|
17
|
+
module ClassMethods
|
18
|
+
def [](*a, **o, &b) = new(*a, **o, &b)
|
29
19
|
end
|
30
20
|
|
31
|
-
def
|
32
|
-
renderer.render(template, locals:, layout: nil)
|
33
|
-
end
|
21
|
+
def self.included(base) = base.extend(ClassMethods)
|
34
22
|
|
35
|
-
def
|
36
|
-
helpers.tag
|
37
|
-
end
|
23
|
+
def t(template, **locals) = renderer.render(inline: template, locals:)
|
38
24
|
|
39
|
-
def
|
40
|
-
block.binding.receiver.capture(&block)
|
41
|
-
end
|
25
|
+
def t!(template, **locals) = renderer.render(template, locals:, layout: nil)
|
42
26
|
|
43
|
-
def
|
44
|
-
Buffer.new(to_s + other.to_s)
|
45
|
-
end
|
27
|
+
def x = helpers.tag
|
46
28
|
|
47
|
-
def
|
48
|
-
to_html
|
49
|
-
end
|
29
|
+
def o(&block) = block.binding.receiver.capture(&block)
|
50
30
|
|
51
|
-
def
|
52
|
-
helpers.capture do
|
53
|
-
if self.class.const_defined?(:TEMPLATE)
|
54
|
-
t(self.class.const_get(:TEMPLATE), c: self, x: self.x )
|
55
|
-
else
|
56
|
-
t!(default_template_name, c: self, x: self.x )
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
31
|
+
def +(other) = Buffer.new(to_s + other.to_s)
|
60
32
|
|
61
|
-
def accepts_slot(block)
|
62
|
-
@_slot = block
|
63
|
-
end
|
33
|
+
def accepts_slot(block) = @_slot = block
|
64
34
|
|
65
|
-
def
|
66
|
-
context = @_slot.binding.receiver
|
35
|
+
def capture(&block) = block.call.to_s.html_safe
|
67
36
|
|
68
|
-
|
69
|
-
end
|
37
|
+
def default_template_name = "shared/#{self.class.name.underscore}"
|
70
38
|
|
71
|
-
def
|
72
|
-
LittleWheels.renderer
|
73
|
-
end
|
39
|
+
def helpers = LittleWheels.helpers
|
74
40
|
|
75
|
-
def
|
76
|
-
LittleWheels.helpers
|
77
|
-
end
|
41
|
+
def renderer = LittleWheels.renderer
|
78
42
|
|
79
|
-
def
|
80
|
-
|
81
|
-
|
43
|
+
def render_in(context) = context.render(:inline => to_html)
|
44
|
+
|
45
|
+
def to_s = to_html
|
46
|
+
|
47
|
+
def slot
|
48
|
+
context = @_slot.binding.receiver
|
82
49
|
|
83
|
-
|
84
|
-
block.call.to_s.html_safe
|
50
|
+
context.capture { @_slot.call.to_s }
|
85
51
|
end
|
86
52
|
|
87
|
-
def
|
88
|
-
|
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
|
89
61
|
end
|
90
62
|
end
|
91
63
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: little_wheels
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gregory Brown
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-12-
|
11
|
+
date: 2024-12-14 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Potential future implementation of the smallest Rails component library
|
14
14
|
that can possibly work.
|
@@ -38,7 +38,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
38
38
|
- !ruby/object:Gem::Version
|
39
39
|
version: '0'
|
40
40
|
requirements: []
|
41
|
-
rubygems_version: 3.
|
41
|
+
rubygems_version: 3.5.9
|
42
42
|
signing_key:
|
43
43
|
specification_version: 4
|
44
44
|
summary: Little Wheels!
|