live 0.8.1 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 622194158e146721f1576806f560d381bb8a5008f8fef87167c68a7c80742fc5
4
- data.tar.gz: dc29461894b0b9b576a68e6961da924e5d8fa3ecff52e73793ff0a1a7fea3381
3
+ metadata.gz: e77327d7651ba96f1312740085897ec0f53430957dacb2d99782d895bf663afc
4
+ data.tar.gz: 4436c155cd68f013986e86da07af57af4238522fc18e8d9161720abe0d47d5ae
5
5
  SHA512:
6
- metadata.gz: 90398bc63e3feccfba94bf1a5680fecb30124fee2bd2ddc95b79344864e6c31309387e781418905b3df2a4908e2a06b5a280867d1e825b8bc49d5d29a6587e92
7
- data.tar.gz: 20e656670a9666e224eafef837aaeaea3a6a74c49e07c4fcbf3823d3f734c766e7587acb4552a946ec79a2344a655478e2465fdc9e237bce3c4d8afddcd89a3f
6
+ metadata.gz: 3a8160a7a68a5cc3ca5d4a00c350cd3147ba583f839fe395f73c1956ae918b2b00b3316067c633a434cc4e13472588caf2ffe4ec5f5d2ba39dd70bdbf8adbf0f
7
+ data.tar.gz: 0b623c52f0408c34eb09d16c5f3b25a609537fa55cb1771c92fa8092ab33baa31c8aeb3596150c014824a8a605b52c7b0630c5b2d80fea94e595d5d7935e53fd
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/live/version.rb CHANGED
@@ -4,5 +4,5 @@
4
4
  # Copyright, 2021-2024, by Samuel Williams.
5
5
 
6
6
  module Live
7
- VERSION = "0.8.1"
7
+ VERSION = "0.10.0"
8
8
  end
data/lib/live/view.rb CHANGED
@@ -9,6 +9,10 @@ require 'xrb/builder'
9
9
  module Live
10
10
  # Represents a single division of content on the page an provides helpers for rendering the content.
11
11
  class View < Element
12
+ def script(code, **options)
13
+ rpc(:script, @id, code, options)
14
+ end
15
+
12
16
  # Update the content of the client-side element by rendering this view.
13
17
  def update!(**options)
14
18
  rpc(:update, @id, self.to_html, options)
@@ -17,22 +21,28 @@ module Live
17
21
  # Replace the content of the client-side element by rendering this view.
18
22
  # @parameter selector [String] The CSS selector to replace.
19
23
  # @parameter node [String] The HTML to replace.
20
- def replace(selector, node, **options)
21
- rpc(:replace, selector, node.to_s, options)
24
+ def replace(selector, fragment = nil, **options, &block)
25
+ fragment ||= XRB::Builder.fragment(&block)
26
+
27
+ rpc(:replace, selector, fragment.to_s, options)
22
28
  end
23
29
 
24
30
  # Prepend to the content of the client-side element by appending the specified element.
25
31
  # @parameter selector [String] The CSS selector to prepend to.
26
32
  # @parameter node [String] The HTML to prepend.
27
- def prepend(selector, node, **options)
28
- rpc(:prepend, selector, node.to_s, options)
33
+ def prepend(selector, fragment = nil, **options, &block)
34
+ fragment ||= XRB::Builder.fragment(&block)
35
+
36
+ rpc(:prepend, selector, fragment.to_s, options)
29
37
  end
30
38
 
31
39
  # Append to the content of the client-side element by appending the specified element.
32
40
  # @parameter selector [String] The CSS selector to append to.
33
41
  # @parameter node [String] The HTML to prepend.
34
- def append(selector, node, **options)
35
- rpc(:append, selector, node.to_s, options)
42
+ def append(selector, fragment = nil, **options, &block)
43
+ fragment ||= XRB::Builder.fragment(&block)
44
+
45
+ rpc(:append, selector, fragment.to_s, options)
36
46
  end
37
47
 
38
48
  # Remove the specified element from the client-side element.
@@ -58,5 +68,11 @@ module Live
58
68
  end
59
69
  end
60
70
  end
71
+
72
+ # Convenience method for rendering the view as a string.
73
+ # @returns [String] The generated HTML.
74
+ def to_s
75
+ to_html.to_s
76
+ end
61
77
  end
62
78
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: live
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
@@ -38,7 +38,7 @@ cert_chain:
38
38
  Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
39
39
  voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
40
40
  -----END CERTIFICATE-----
41
- date: 2024-05-06 00:00:00.000000000 Z
41
+ date: 2024-05-12 00:00:00.000000000 Z
42
42
  dependencies:
43
43
  - !ruby/object:Gem::Dependency
44
44
  name: async-websocket
metadata.gz.sig CHANGED
Binary file