evc_rails 0.2.1 → 0.2.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5fa808d0d2dcb0efe2ff7a1807cbfabfb62995594731b066eb718e3aac9e1ee3
4
- data.tar.gz: fc944ac269042805ec1bb1c9175a4646ac56ed4a3ac2461c6061c211c831b608
3
+ metadata.gz: fb8d4d59a3526f01f08e3c152ff5abe083e1a2bf1e66ab929db733356b56c822
4
+ data.tar.gz: 07c8c5688a9ad4ddb78f34ca174f478e9103b656c09223c86aed522746b0b299
5
5
  SHA512:
6
- metadata.gz: 197a8e203c89e35b9a2365b38d40a9c24c042045a9ea654538f9fa5eb860778d7a1312231c921d6a7b9119cc41869ece6240ce5af201a4c94420406a5f02f228
7
- data.tar.gz: 0ae04a20540c3ad665ac2b7309e1053bdb200ca6f0a9c439752904ff9400fb6ce45defbe15cc620256a6959dd7b2c2b46489bea45921c1d44b09ea813a86f000
6
+ metadata.gz: 6e429ae91cf3b0e3ac7b47001e164e65f6c4c6bd45f6c11f4258bb0a3c7cf77fa04594a4f493b887f434809ff11174996b09099273ac1bfac50897b002489158
7
+ data.tar.gz: 57c5fb478a987d55dd24e22afda9198f9af0b11056ac3ab2bbf66a52ec420251cae33cfa596caa5074015e241cd5d6754b2f95a04c46ba1951c0190694f92e64
data/README.md CHANGED
@@ -176,6 +176,22 @@ There are two ways to pass information to a component:
176
176
  - **As attributes:** Data passed as attributes on the main component tag (e.g. `<Card title="...">`) is sent to its `initialize` method.
177
177
  - **As slot content:** Rich content passed via `<With...>` tags is used to populate the component's named slots.
178
178
 
179
+ #### Boolean Attribute Shorthand
180
+
181
+ You can use HTML-style boolean attributes in EVC. If you specify an attribute with no value, it will be passed as `true` to your component initializer. This makes templates more concise and readable:
182
+
183
+ ```erb
184
+ <Button disabled required />
185
+ ```
186
+
187
+ is equivalent to:
188
+
189
+ ```erb
190
+ <%= render ButtonComponent.new(disabled: true, required: true) %>
191
+ ```
192
+
193
+ This works for any boolean parameter your component defines.
194
+
179
195
  #### When a Block Variable is Yielded
180
196
 
181
197
  The contextual variable (e.g., `|card|`) is only yielded if one or more `<With...>` slot tags are present inside the component block. If you render a component like `<Card></Card>` with no slots inside, `evc_rails` is smart enough to render it without the `do |card|` part.
@@ -13,7 +13,7 @@ module EvcRails
13
13
  CLOSE_TAG_REGEX = %r{</([A-Z][a-zA-Z0-9_]*(?:::[A-Z][a-zA-Z0-9_]*)*)>}
14
14
 
15
15
  # Regex for attributes
16
- ATTRIBUTE_REGEX = /(\w+)=(?:"([^"]*)"|'([^']*)'|\{([^}]*)\})/
16
+ ATTRIBUTE_REGEX = /(\w+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|\{([^}]*)\}))?/
17
17
 
18
18
  # Cache for compiled templates
19
19
  @template_cache = {}
@@ -254,13 +254,16 @@ module EvcRails
254
254
 
255
255
  params = []
256
256
  attributes_str.scan(attribute_regex) do |key, quoted_value, single_quoted_value, ruby_expression|
257
- if ruby_expression
258
- params << "#{key}: #{ruby_expression}"
259
- elsif quoted_value
260
- params << "#{key}: \"#{quoted_value.gsub('"', '\\"')}\""
261
- elsif single_quoted_value
262
- params << "#{key}: \"#{single_quoted_value.gsub("'", "\\'")}\""
263
- end
257
+ params << if ruby_expression
258
+ "#{key}: #{ruby_expression}"
259
+ elsif quoted_value
260
+ "#{key}: \"#{quoted_value.gsub('"', '\\"')}\""
261
+ elsif single_quoted_value
262
+ "#{key}: \"#{single_quoted_value.gsub("'", "\\'")}\""
263
+ else
264
+ # Standalone attribute (no value) - treat as boolean true
265
+ "#{key}: true"
266
+ end
264
267
  end
265
268
  [params, as_variable]
266
269
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EvcRails
4
- VERSION = "0.2.1"
4
+ VERSION = "0.2.2"
5
5
  end
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.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - scttymn