evc_rails 0.1.3 → 0.2.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 +54 -27
- data/lib/evc_rails/template_handler.rb +11 -2
- data/lib/evc_rails/version.rb +1 -1
- metadata +8 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1595c9c520d1639384e46e39fce8f611edbe3b27707a9f99ab412bb25a1741f0
|
4
|
+
data.tar.gz: 23ec6c266ec28a617b0d39d255f33fd5cff58c3db6461dd4382237b8d1989ef2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 78e5db590a2dd0b84df663fc836b51c24156bf6f5af40d278f8a5a9ec2cd89aa9ddf1fc83a957613ecc980ebfd54e2fa4d84c33e48f910d2c48514d0869789b7
|
7
|
+
data.tar.gz: c2765e0f368bce11454d9bf95461739a62ef0b89a1d1940c6e069f305499a20e4aeba6dabb4bd017ebc4f1bbefbd60294e0f8ecf53c24e377662a04d16e21cce
|
data/README.md
CHANGED
@@ -28,9 +28,9 @@ class ButtonComponent < ViewComponent::Base
|
|
28
28
|
end
|
29
29
|
```
|
30
30
|
|
31
|
-
```
|
31
|
+
```erb
|
32
32
|
<!-- Now you can use it with EVC syntax -->
|
33
|
-
<
|
33
|
+
<Button variant="primary" size="lg">Click me</Button>
|
34
34
|
```
|
35
35
|
|
36
36
|
No component modifications required - just install and enjoy easier syntax!
|
@@ -69,11 +69,11 @@ The template handler will be automatically registered for `.evc` files.
|
|
69
69
|
|
70
70
|
Create `.evc` files in your `app/views` directory:
|
71
71
|
|
72
|
-
```
|
72
|
+
```erb
|
73
73
|
<!-- app/views/pages/home.evc -->
|
74
74
|
<h1>Welcome to our app</h1>
|
75
75
|
|
76
|
-
<
|
76
|
+
<Button size="lg" variant="primary">Get Started</Button>
|
77
77
|
|
78
78
|
<Card>
|
79
79
|
<h2>Featured Content</h2>
|
@@ -98,10 +98,10 @@ This becomes:
|
|
98
98
|
|
99
99
|
### Self-Closing Components
|
100
100
|
|
101
|
-
```
|
102
|
-
<
|
101
|
+
```erb
|
102
|
+
<Button />
|
103
103
|
<Icon name="star" />
|
104
|
-
<
|
104
|
+
<Spacer height="20" />
|
105
105
|
```
|
106
106
|
|
107
107
|
Becomes:
|
@@ -116,20 +116,20 @@ Becomes:
|
|
116
116
|
|
117
117
|
#### String Attributes
|
118
118
|
|
119
|
-
```
|
120
|
-
<
|
119
|
+
```erb
|
120
|
+
<Button size="lg" variant="primary" />
|
121
121
|
```
|
122
122
|
|
123
123
|
#### Ruby Expressions
|
124
124
|
|
125
|
-
```
|
126
|
-
<
|
125
|
+
```erb
|
126
|
+
<Button user={@current_user} count={@items.count} />
|
127
127
|
```
|
128
128
|
|
129
129
|
#### Multiple Attributes
|
130
130
|
|
131
|
-
```
|
132
|
-
<Card class="shadow-lg" data-testid="featured-card" user=
|
131
|
+
```erb
|
132
|
+
<Card class="shadow-lg" data-testid="featured-card" user={@user}>
|
133
133
|
Content here
|
134
134
|
</Card>
|
135
135
|
```
|
@@ -138,9 +138,9 @@ Becomes:
|
|
138
138
|
|
139
139
|
Organize your components in subdirectories:
|
140
140
|
|
141
|
-
```
|
141
|
+
```erb
|
142
142
|
<UI::Button size="lg" />
|
143
|
-
<Forms::Fields::TextField value=
|
143
|
+
<Forms::Fields::TextField value={@email} />
|
144
144
|
<Layout::Container class="max-w-4xl">
|
145
145
|
<UI::Card>Content</UI::Card>
|
146
146
|
</Layout::Container>
|
@@ -164,14 +164,14 @@ class CardComponent < ViewComponent::Base
|
|
164
164
|
end
|
165
165
|
```
|
166
166
|
|
167
|
-
```
|
167
|
+
```erb
|
168
168
|
<Card>
|
169
|
-
<
|
169
|
+
<WithHeader>
|
170
170
|
<h1>Welcome</h1>
|
171
|
-
</
|
172
|
-
<
|
171
|
+
</WithHeader>
|
172
|
+
<WithBody>
|
173
173
|
<p>This is the body content.</p>
|
174
|
-
</
|
174
|
+
</WithBody>
|
175
175
|
</Card>
|
176
176
|
```
|
177
177
|
|
@@ -197,11 +197,11 @@ class ListComponent < ViewComponent::Base
|
|
197
197
|
end
|
198
198
|
```
|
199
199
|
|
200
|
-
```
|
200
|
+
```erb
|
201
201
|
<List>
|
202
|
-
<
|
203
|
-
<
|
204
|
-
<
|
202
|
+
<WithItem>Item 1</WithItem>
|
203
|
+
<WithItem>Item 2</WithItem>
|
204
|
+
<WithItem>Item 3</WithItem>
|
205
205
|
</List>
|
206
206
|
```
|
207
207
|
|
@@ -215,9 +215,36 @@ Becomes:
|
|
215
215
|
<% end %>
|
216
216
|
```
|
217
217
|
|
218
|
+
#### Complex Slot Examples
|
219
|
+
|
220
|
+
```erb
|
221
|
+
<Navigation>
|
222
|
+
<WithLink href={learning_path} text="Learning Path" />
|
223
|
+
<WithLink href={courses_path} text="All Courses" />
|
224
|
+
<WithLink text="Reports">
|
225
|
+
<WithSublink href={reports_users_path} text="Users" />
|
226
|
+
<WithSublink href={reports_activity_path} text="Activity" />
|
227
|
+
</WithLink>
|
228
|
+
<WithFooter>
|
229
|
+
<div>Footer content</div>
|
230
|
+
</WithFooter>
|
231
|
+
</Navigation>
|
232
|
+
```
|
233
|
+
|
234
|
+
#### Backward Compatibility
|
235
|
+
|
236
|
+
The old `Component::slotname` syntax is still supported for backward compatibility:
|
237
|
+
|
238
|
+
```erb
|
239
|
+
<Card>
|
240
|
+
<Card::header>Title</Card::header>
|
241
|
+
<Card::body>Content</Card::body>
|
242
|
+
</Card>
|
243
|
+
```
|
244
|
+
|
218
245
|
### Complex Nesting
|
219
246
|
|
220
|
-
```
|
247
|
+
```erb
|
221
248
|
<UI::Card>
|
222
249
|
<h2 class="text-2xl font-semibold">Dashboard</h2>
|
223
250
|
|
@@ -239,7 +266,7 @@ Becomes:
|
|
239
266
|
|
240
267
|
You can mix regular HTML, ERB, and component tags:
|
241
268
|
|
242
|
-
```
|
269
|
+
```erb
|
243
270
|
<div class="container">
|
244
271
|
<h1><%= @page.title %></h1>
|
245
272
|
|
@@ -249,7 +276,7 @@ You can mix regular HTML, ERB, and component tags:
|
|
249
276
|
|
250
277
|
<div class="grid">
|
251
278
|
<% @posts.each do |post| %>
|
252
|
-
<PostCard post=
|
279
|
+
<PostCard post={post} />
|
253
280
|
<% end %>
|
254
281
|
</div>
|
255
282
|
</div>
|
@@ -109,14 +109,23 @@ module EvcRails
|
|
109
109
|
# Add content before the tag
|
110
110
|
result << source[pos...match.begin(0)] if pos < match.begin(0)
|
111
111
|
|
112
|
-
# Determine if this is a slot (e.g., Card::Header inside Card)
|
112
|
+
# Determine if this is a slot (e.g., WithHeader, WithPost, or Card::Header inside Card)
|
113
113
|
parent = stack.last
|
114
114
|
is_slot = false
|
115
115
|
slot_name = nil
|
116
116
|
slot_parent = nil
|
117
117
|
if parent
|
118
118
|
parent_tag = parent[0]
|
119
|
-
|
119
|
+
|
120
|
+
# Check for WithSlotName syntax (e.g., WithHeader, WithPost)
|
121
|
+
if tag_name.start_with?("With")
|
122
|
+
is_slot = true
|
123
|
+
slot_name = tag_name[4..-1].downcase # Remove "With" prefix and convert to lowercase
|
124
|
+
slot_parent = parent_tag
|
125
|
+
# Mark parent as having a slot
|
126
|
+
parent[6] = true
|
127
|
+
# Check for Component::slotname syntax (backward compatibility)
|
128
|
+
elsif tag_name.start_with?("#{parent_tag}::")
|
120
129
|
is_slot = true
|
121
130
|
slot_name = tag_name.split("::").last.downcase
|
122
131
|
slot_parent = parent_tag
|
data/lib/evc_rails/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: evc_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- scttymn
|
@@ -65,9 +65,11 @@ dependencies:
|
|
65
65
|
- - ">="
|
66
66
|
- !ruby/object:Gem::Version
|
67
67
|
version: '2.0'
|
68
|
-
description:
|
69
|
-
allowing
|
70
|
-
|
68
|
+
description: Embedded ViewComponents (EVC) is a Rails template handler that brings
|
69
|
+
JSX-like syntax to ViewComponent, allowing you to write custom component tags directly
|
70
|
+
in your .evc templates. It's a drop-in replacement for .erb files that works seamlessly
|
71
|
+
with existing ViewComponents, supporting self-closing tags, attributes, namespaced
|
72
|
+
components, slots, and complex nesting while maintaining full ERB compatibility.
|
71
73
|
email:
|
72
74
|
- scotty@hey.com
|
73
75
|
executables: []
|
@@ -90,6 +92,7 @@ metadata:
|
|
90
92
|
allowed_push_host: https://rubygems.org
|
91
93
|
homepage_uri: https://github.com/scttymn/evc_rails
|
92
94
|
source_code_uri: https://github.com/scttymn/evc_rails
|
95
|
+
changelog_uri: https://github.com/scttymn/evc_rails/blob/main/CHANGELOG.md
|
93
96
|
rdoc_options: []
|
94
97
|
require_paths:
|
95
98
|
- lib
|
@@ -106,5 +109,5 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
106
109
|
requirements: []
|
107
110
|
rubygems_version: 3.6.9
|
108
111
|
specification_version: 4
|
109
|
-
summary:
|
112
|
+
summary: JSX-like syntax for Rails ViewComponent
|
110
113
|
test_files: []
|