little_wheels 0.0.5 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/little_wheels.rb +26 -2
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1239b1153781bf67297befc609b59aaf899cb14cf1626d1c69501a98dde62997
4
- data.tar.gz: 56876fa5ab4ab7a25386fd7ea876346f2f5dcf0119357b695219259a3dc01f9e
3
+ metadata.gz: 7366ace87bb341e2c4bfb019995eb3a167d3226827e13c0f281627e4766df1c8
4
+ data.tar.gz: c036705390e96b03ad3da97a058a074f8e8cd4203c76c61577f6a2e46cad3a06
5
5
  SHA512:
6
- metadata.gz: 7ff56bd1ad67c62cf809fb7fd41989830df7a5e015cae8dcf82a6541ba8289e2316b4fc9a16195f42cf641d1e5380bf6a7a4d53212ad1478defbe47911038bec
7
- data.tar.gz: ec0e843354fe1d928d9cebbea6be21655afe9bcf6559c0047bc4e4109e0160374f0b1a924458ad2133dc4f64b863f6be91811533a9e8c20341f6df73312b9a27
6
+ metadata.gz: f354ab4ede76e3c7c22a47a7fd32fc7b13c2912227a7fd0c1a2fe204b683642c8264d63f2406db4b99c7f124a3e6a8bb967ce8ab6bdc4cbf64ab21f28084de99
7
+ data.tar.gz: 3b7f8431bf6aa8ab06a76b7e62696a2ad0e551c35934a9cfae889fdd8bb8eba1aabcecdd50ffd97ee4173861cba079f9fa503e164231c4f76ed5bac00c9377de
data/lib/little_wheels.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module LittleWheels
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.7"
3
3
 
4
4
  class Component
5
5
  def t(template, **locals)
@@ -9,9 +9,29 @@ module LittleWheels
9
9
  def t!(template, **locals)
10
10
  renderer.render(template, locals:, layout: nil)
11
11
  end
12
+
13
+ def x
14
+ renderer.helpers.tag
15
+ end
12
16
 
13
17
  def to_s
14
- self.class.const_defined?("TEMPLATE") ? t(self.class.const_get("TEMPLATE"), c: self) : t!("shared/#{default_template_name}", c: self)
18
+ renderer.helpers.capture do
19
+ if self.class.const_defined?(:TEMPLATE)
20
+ t(self.class.const_get(:TEMPLATE), c: self, x: self.x )
21
+ else
22
+ t!("shared/#{default_template_name}", c: self, x: self.x )
23
+ end
24
+ end
25
+ end
26
+
27
+ def accepts_slot(block)
28
+ @_slot = block
29
+ end
30
+
31
+ def slot
32
+ context = @_slot.binding.receiver
33
+
34
+ context.capture(&@_slot)
15
35
  end
16
36
 
17
37
  def renderer
@@ -21,5 +41,9 @@ module LittleWheels
21
41
  def default_template_name
22
42
  self.class.name.underscore
23
43
  end
44
+
45
+ def capture(&block)
46
+ block.call.to_s.html_safe
47
+ end
24
48
  end
25
49
  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.5
4
+ version: 0.0.7
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-11-27 00:00:00.000000000 Z
11
+ date: 2024-11-30 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.