little_wheels 0.0.6 → 0.0.8

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 +37 -7
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 616606ae8e7023b6c4ac0c6f0eae31f82efde79174e898d4d5734123395626cb
4
- data.tar.gz: 7bf2324aa9e21130169d81c300045320ceb0c822179c637a8ba0063afa960ef6
3
+ metadata.gz: 0e5a89103fef26ef5663ad1f7cfd215865f67863dabe703e9e50454f32edba48
4
+ data.tar.gz: 3c633c615464ab951210f5dde9156f59577ab625932bd5abcacbc6fcc5b5fe5d
5
5
  SHA512:
6
- metadata.gz: 54507f465e5acdb3455952167a6258ba649584b69a08f40b27d1d63acc1fb81436e65e434a2687647c0daaeb4b0e6d2287ed11255d52cefa626e3d9ed275de04
7
- data.tar.gz: 6cbc031dd4984a21b50a24664725fa4d1bbe6ca72fec9f15c21d1f7c9fab4ea2012dd2935c5ce3b27eccd56ebc4a7a0306d9984eb96c82b06ef04c0e3109fa14
6
+ metadata.gz: 83b59a0c1929aca554daaea53c164878df50ba600133c96f7f40c3a11cdcbdc6164ebbbe14a04ee2aea0c3aa30ab6a26bf024f1b186eb061d690ee97112dde0a
7
+ data.tar.gz: 4495c71f386fb712b41f8540d3bc21c13b12094638ac6d39d7d7d7fdeaac326cc527ea54dad179a0b4522100c5684de930f27c1f0617712fcde06ab69d4f7a61
data/lib/little_wheels.rb CHANGED
@@ -1,7 +1,21 @@
1
1
  module LittleWheels
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.8"
3
3
 
4
- class Component
4
+ class Buffer
5
+ def initialize(string)
6
+ @string = string.html_safe
7
+ end
8
+
9
+ def +(other)
10
+ self.class.new(@string + other.to_s)
11
+ end
12
+
13
+ def to_s
14
+ @string
15
+ end
16
+ end
17
+
18
+ module Component
5
19
  def t(template, **locals)
6
20
  renderer.render(inline: template, locals:)
7
21
  end
@@ -9,21 +23,33 @@ module LittleWheels
9
23
  def t!(template, **locals)
10
24
  renderer.render(template, locals:, layout: nil)
11
25
  end
12
-
26
+
13
27
  def x
14
- renderer.helpers.tag
28
+ helpers.tag
29
+ end
30
+
31
+ def o(&block)
32
+ block.binding.receiver.capture(&block)
15
33
  end
16
34
 
35
+ def +(other)
36
+ Buffer.new(to_s + other.to_s)
37
+ end
38
+
17
39
  def to_s
18
- renderer.helpers.capture do
40
+ helpers.capture do
19
41
  if self.class.const_defined?(:TEMPLATE)
20
42
  t(self.class.const_get(:TEMPLATE), c: self, x: self.x )
21
43
  else
22
- t!("shared/#{default_template_name}", c: self, x: self.x )
44
+ t!(default_template_name, c: self, x: self.x )
23
45
  end
24
46
  end
25
47
  end
26
48
 
49
+ def helpers
50
+ renderer.helpers
51
+ end
52
+
27
53
  def accepts_slot(block)
28
54
  @_slot = block
29
55
  end
@@ -39,7 +65,11 @@ module LittleWheels
39
65
  end
40
66
 
41
67
  def default_template_name
42
- self.class.name.underscore
68
+ "shared/#{self.class.name.underscore}"
69
+ end
70
+
71
+ def capture(&block)
72
+ block.call.to_s.html_safe
43
73
  end
44
74
  end
45
75
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: little_wheels
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gregory Brown
@@ -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.1.2
41
+ rubygems_version: 3.5.9
42
42
  signing_key:
43
43
  specification_version: 4
44
44
  summary: Little Wheels!