s2p 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.
- checksums.yaml +4 -4
- data/lib/s2p/component.rb +26 -28
- data/lib/s2p/version.rb +1 -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: b5f9cb12cda3baf072ec25f383b9d78fbd3cfc8b78b3bfef30e4179af8ed2353
|
4
|
+
data.tar.gz: ef36f907821b6feef6ff11cf62f7c49b8cbff113f2295a482dd06cae790878b6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c5a92cd059802f9fac29305b15832cf078523e1de518ff37301c80b513e598cc8fa59e6e8ab83ff1edfb70523f126429d14e3b08a0264d523809e3ea12324e92
|
7
|
+
data.tar.gz: a9c59837be3d2f3b370bf5925b4820f1e85f23f54ef42dae075be4206988c61690315e5f3e208901586e0a7d10c9a17916f25a765a9af685d9ec5b69ff0c0323
|
data/lib/s2p/component.rb
CHANGED
@@ -12,50 +12,48 @@ module S2P
|
|
12
12
|
def to_s = @string
|
13
13
|
end
|
14
14
|
|
15
|
-
module
|
16
|
-
|
17
|
-
|
18
|
-
end
|
15
|
+
module ClassMethods
|
16
|
+
def [](*a, **o, &b) = new(*a, **o, &b)
|
17
|
+
end
|
19
18
|
|
20
|
-
|
19
|
+
def self.included(base) = base.extend(ClassMethods)
|
21
20
|
|
22
|
-
|
21
|
+
def t(template, **locals) = renderer.render(inline: template, locals:)
|
23
22
|
|
24
|
-
|
23
|
+
def t!(template, **locals) = renderer.render(template, locals:, layout: nil)
|
25
24
|
|
26
|
-
|
25
|
+
def x = helpers.tag
|
27
26
|
|
28
|
-
|
27
|
+
def o(&block) = block.binding.receiver.capture(&block)
|
29
28
|
|
30
|
-
|
29
|
+
def +(other) = Buffer.new(to_s + other.to_s)
|
31
30
|
|
32
|
-
|
31
|
+
def accepts_slot(block) = @_slot = block
|
33
32
|
|
34
|
-
|
33
|
+
def capture(&block) = block.call.to_s.html_safe
|
35
34
|
|
36
|
-
|
35
|
+
def default_template_name = "shared/#{self.class.name.underscore}"
|
37
36
|
|
38
|
-
|
37
|
+
def helpers = LittleWheels.helpers
|
39
38
|
|
40
|
-
|
39
|
+
def renderer = LittleWheels.renderer
|
41
40
|
|
42
|
-
|
41
|
+
def render_in(context) = context.render(:inline => to_html)
|
43
42
|
|
44
|
-
|
43
|
+
def to_s = to_html
|
45
44
|
|
46
|
-
|
47
|
-
|
45
|
+
def slot
|
46
|
+
context = @_slot.binding.receiver
|
48
47
|
|
49
|
-
|
50
|
-
|
48
|
+
context.capture { @_slot.call.to_s }
|
49
|
+
end
|
51
50
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
end
|
51
|
+
def to_html
|
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 )
|
59
57
|
end
|
60
58
|
end
|
61
59
|
end
|
data/lib/s2p/version.rb
CHANGED