isorun 0.1.9 → 0.1.11

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: 420234426bc37f5156c255fbc0e458e25379847729ad40b4d2ce7f61c2251ad6
4
- data.tar.gz: 222c11ca81c54fb7b8cb1a3783b2caa33e1b5bb4d670ed4b8d67620fabb648f8
3
+ metadata.gz: 724881750024f3660d4f7219113d5fe5a13bdb53c5e31edf8cad5bb4ef5bb5ff
4
+ data.tar.gz: 156a1e08ccf8613c5652c7414c305d2d55c3080de11a6414f07e72817dc48240
5
5
  SHA512:
6
- metadata.gz: acee923f0800c7d0c47e77d6f61a4fed10d32d7e715145af1ecd8d1dfa25c47e1e58e24bcc65e886fd725a53d8f0ca3fab68b4e7ec91e4cf1ba83c1a8ea07b64
7
- data.tar.gz: 5988611ab658bf3345b37a1fb0516e5c236f14bbc773ce1c364759b185ec1f1207c4bba3d448b52f93e2852834f4ad6cc4b6291ff00f3e651ac293cc5ba01749
6
+ metadata.gz: '09398ad2ec130ec4a559a3bf78d063c0b6a5c15cc0cf7ad6b745048598c6eb4b8f3add11e3c2e58f841d78f802ff13ebfd13b4017a50c8f14a8cd396a84161b9'
7
+ data.tar.gz: cc650db902d6c942ec49743f76543a1812b5ef3772f953796902a27919a4ffd4a375ab0d5fc7c48c2d0bdc06ec44a96ff47993a9ca7a5e321eb10432208deced
@@ -14,16 +14,20 @@ module Isorun
14
14
  # </body>
15
15
  # </html>
16
16
  #
17
+ # @see https://api.rubyonrails.org/v5.1/classes/ActionView/Helpers/TagHelper.html#method-i-tag
17
18
  # @param id [String] An ID representing both, the asset bundle, and by
18
19
  # convention, the target node (e.g. `<div id="my_app">`)
20
+ # @param [Hash] options All valid tag options can also passed as options
21
+ # to this method
22
+ # @param [Hash, nil] ctx Pass variables to render context
19
23
  # @return [String]
20
- def isorun_app(id) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
24
+ def isorun_app(id, options = nil, ctx: nil) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
21
25
  ActiveSupport::Notifications.instrument "start.render.isorun", { ts: Time.current }
22
26
 
23
27
  module_path = Isorun.config.module_resolver.call(id)
24
28
 
25
29
  ssr_html = Isorun::Context.create(receiver: Isorun.config.receiver) do |context|
26
- render_context = { environment: Rails.env.to_s }
30
+ render_context = { environment: Rails.env.to_s }.merge(ctx)
27
31
  render_function = context.import.from(module_path)
28
32
 
29
33
  if render_function.blank?
@@ -43,7 +47,10 @@ module Isorun
43
47
  end
44
48
 
45
49
  html = if ssr_html.present?
46
- tag.div id: id do
50
+ options ||= {}
51
+ options[:id] = id
52
+
53
+ tag.div(**options) do
47
54
  ssr_html.html_safe # rubocop:disable Rails/OutputSafety
48
55
  end
49
56
  else
@@ -15,10 +15,14 @@ module Isorun
15
15
  # </body>
16
16
  # </html>
17
17
  #
18
- # @param id [String] An ID representing both, the asset bundle, and by
18
+ # @see https://api.rubyonrails.org/v5.1/classes/ActionView/Helpers/TagHelper.html#method-i-tag
19
+ # @param [String] id An ID representing both, the asset bundle, and by
19
20
  # convention, the target node (e.g. `<div id="my_app">`)
21
+ # @param [Hash] options All valid tag options can also passed as options
22
+ # to this method
23
+ # @param [Hash, nil] ctx Pass variables to render context
20
24
  # @return [String]
21
- def isorun_vite_app(id) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
25
+ def isorun_vite_app(id, options = nil, ctx: nil)
22
26
  ActiveSupport::Notifications.instrument "start.render.isorun", { ts: Time.current }
23
27
 
24
28
  # if id has a file extension, we extract the extension and reduce the ID
@@ -29,7 +33,7 @@ module Isorun
29
33
  module_path = Isorun.config.module_resolver.call(id)
30
34
 
31
35
  ssr_html = Isorun::Context.create(receiver: Isorun.config.receiver) do |context|
32
- render_context = { environment: Rails.env.to_s }
36
+ render_context = { environment: Rails.env.to_s }.merge(ctx)
33
37
  render_function = context.import.from(module_path)
34
38
 
35
39
  if render_function.blank?
@@ -49,7 +53,10 @@ module Isorun
49
53
  end
50
54
 
51
55
  html = if ssr_html.present?
52
- tag.div id: id do
56
+ options ||= {}
57
+ options[:id] = id
58
+
59
+ tag.div(**options) do
53
60
  ssr_html.html_safe # rubocop:disable Rails/OutputSafety
54
61
  end
55
62
  else
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "isorun"
3
- version = "0.1.9"
3
+ version = "0.1.11"
4
4
  edition = "2021"
5
5
  authors = ["Hannes Moser <box@hannesmoser.at>"]
6
6
  homepage = "https://github.com/eliias/isorun"
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Isorun
4
- VERSION = "0.1.9"
4
+ VERSION = "0.1.11"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: isorun
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.1.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hannes Moser
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-01-31 00:00:00.000000000 Z
11
+ date: 2023-02-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties