svelte-on-rails 7.0.1 → 7.1.0
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/README.md +10 -24
- data/lib/svelte_on_rails/view_helpers.rb +22 -4
- 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: 3d0391b58c56174ccd55c88487ebb02e71da117ee56834c7a271757cc2f9e4be
|
4
|
+
data.tar.gz: a0c3f07377ed6fa3b5ce816d72674aa2e2cba02c63ac55c1975a2ce6dfb5b8a2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0fdf719228d92a54f0ee763c56493cb344521589f5cd6202f97a1779e35a5e9f9e5eda9c912ddcbd43695654729fcd3d5493a868c85ae8cfa9eed9ad504d9d29
|
7
|
+
data.tar.gz: 034c37f56fa009208ca065b88350048ebc612dbded303bf2bfa8cb36c83b7060c758555ae085ad830a85a030ab35ceec66c93c15b081f1ad8bc21a725242cef1
|
data/README.md
CHANGED
@@ -11,29 +11,7 @@ Realizing [DHH's vision](https://rubyonrails.org/2021/12/15/Rails-7-fulfilling-a
|
|
11
11
|
|
12
12
|
Svelte offers the simplest and most elegant soulution to building reactive, high-performance front-end components.
|
13
13
|
|
14
|
-
|
15
|
-
- Full-stack development delivers maximum value:
|
16
|
-
- Unified testing from database to frontend
|
17
|
-
- Single-source system delivery
|
18
|
-
- For the most HTML Hotwired is enough
|
19
|
-
- **Compared to integrated React or Vue**
|
20
|
-
- No virtual DOM, resulting in leaner packages and faster performance
|
21
|
-
- See Rich Harris’ [Rethinking Reactivity](https://svelte.dev/blog/svelte-3-rethinking-reactivity) (3:50–6:40) for a compelling comparison
|
22
|
-
- Easier to learn
|
23
|
-
- While React and Vue have larger communities, Svelte’s ecosystem is robust and growing, ideal for Rails integration
|
24
|
-
- **Compared to Hotwired**
|
25
|
-
- Stimulus is a initializer, but not a tool for frontend-apps!
|
26
|
-
- Svelte eliminates redundant HTML initial state logic
|
27
|
-
- Consolidates component logic into a single file
|
28
|
-
- Offloads rendering to JavaScript by Frontend, Server side Rendering only where necessary, reducing server load
|
29
|
-
- **Seamless Integration**
|
30
|
-
- Works flawlessly with Hotwired/Turbo
|
31
|
-
- Enhances Hotwire’s capabilities
|
32
|
-
- **Developer-Friendly**
|
33
|
-
- Simple to learn, intuitive, and powerful
|
34
|
-
- Lightning-fast performance
|
35
|
-
|
36
|
-
Svelte empowers Rails’ full-stack vision with modern, efficient front-end integration.
|
14
|
+
See: [Comparitions on the guide](https://svelte-on-rails-docs-51acfa.gitlab.io/about/why.html)
|
37
15
|
|
38
16
|
# Features
|
39
17
|
|
@@ -72,6 +50,10 @@ If you have issues, please open one, and contributors are welcome!
|
|
72
50
|
- When `.nvmrc` is present on projects root, it is respected
|
73
51
|
- If node is not included on the PATH you can configure your node path by environment variable `SVELTE_ON_RAILS_NODE_BIN`
|
74
52
|
|
53
|
+
**PROPS ON RUBY <= 3**
|
54
|
+
|
55
|
+
|
56
|
+
|
75
57
|
|
76
58
|
## Installation
|
77
59
|
|
@@ -107,7 +89,11 @@ Add it to the view
|
|
107
89
|
<%= svelte_component('HelloWorld', {title: 'Hello World'}) %>
|
108
90
|
```
|
109
91
|
|
110
|
-
And you
|
92
|
+
And you will see "Svelte Hello World" on the browser! 👍 🤗
|
93
|
+
|
94
|
+
# Contributors welcome
|
95
|
+
|
96
|
+
see [Guide / run your first test](https://svelte-on-rails-docs-51acfa.gitlab.io/first_test.html)
|
111
97
|
|
112
98
|
|
113
99
|
## Licence
|
@@ -2,9 +2,11 @@
|
|
2
2
|
module SvelteOnRails
|
3
3
|
module ViewHelpers
|
4
4
|
|
5
|
-
def svelte_component(path, props = {}, html: {}, options: {})
|
5
|
+
def svelte_component(path, props = {}, html: {}, options: {}, _props: {})
|
6
6
|
|
7
|
-
|
7
|
+
prp = validate_props(props, _props)
|
8
|
+
|
9
|
+
support = SvelteOnRails::Lib::ViewHelperSupport.new(path, prp, html, options, request, false)
|
8
10
|
|
9
11
|
support.debug_log("Rendering component: #{path}")
|
10
12
|
log_message = '?'
|
@@ -18,9 +20,11 @@ module SvelteOnRails
|
|
18
20
|
|
19
21
|
end
|
20
22
|
|
21
|
-
def cached_svelte_component(path, props = {}, html: {}, options: {})
|
23
|
+
def cached_svelte_component(path, props = {}, html: {}, options: {}, _props: {})
|
24
|
+
|
25
|
+
prp = validate_props(props, _props)
|
22
26
|
|
23
|
-
support = SvelteOnRails::Lib::ViewHelperSupport.new(path,
|
27
|
+
support = SvelteOnRails::Lib::ViewHelperSupport.new(path, prp, html, options, request, true)
|
24
28
|
|
25
29
|
log_message = '?'
|
26
30
|
redis = support.conf.redis_instance
|
@@ -94,5 +98,19 @@ module SvelteOnRails
|
|
94
98
|
end
|
95
99
|
end
|
96
100
|
|
101
|
+
def validate_props(props, _props)
|
102
|
+
if props.present? && _props.present?
|
103
|
+
raise "you can only pass props as the first argument OR use the _props keyword argument. the latter only is made as workaround for Apps <= ruby-3"
|
104
|
+
end
|
105
|
+
if RUBY_VERSION.split('.').first.to_i >= 3 && _props.present?
|
106
|
+
raise "The _props keyword-argument is only meant as workaround for Apps <= ruby-3 because of avoiding misinterpreting hash as keyword arguments"
|
107
|
+
end
|
108
|
+
if props.present?
|
109
|
+
props
|
110
|
+
else
|
111
|
+
_props
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
97
115
|
end
|
98
116
|
end
|