evc_rails 0.3.1 → 0.3.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: cbedccd24baa2e896e5f5dc2f232b1a481ac3e5c9e82653f18d6d40d3b888f8d
4
- data.tar.gz: 022e8e06c631aa3d6d52363377600a9b38870ffaa0506e1d5e732c0bf6859b73
3
+ metadata.gz: 176929bf44d50fb5c8e783d6cdd745c02f09d500b59daf5838f7b0a6f2fdda28
4
+ data.tar.gz: 285435052b2267b961ff7b670738abdccca2f9b0ad89ecc7eca8508b81a6ce8f
5
5
  SHA512:
6
- metadata.gz: b0eca6627b253da66c7cc9d44730f0c7dff6306ae6040bae1ac08b294d59723f72d0a3ec2ffc67736de566b7e6567803e2f17c14590c17e0ec1952d96005309a
7
- data.tar.gz: 0a1268f2b06d7027134d9277b2a48b1372e6483e6c8c08fdd0e2aed1b36f4bf81286edbce9b760a18435ff64f11f2e6fa06a5ba9008af22efe9f24e950daa104
6
+ metadata.gz: aab13dc98534d5888de5756a7cb6ff90e993a882db66f689914d3e68b755f51cc7871f4b1a6b8f59e9a8fe6a99695d7935d584ff8790e3c13f17aa05ca981c78
7
+ data.tar.gz: e71dc0b00125dd83ea4f1c8f4734e756cdbbc38e6d0892121d5274cac47e3ae40432c83de6a29abd9c7bfce0998d6d223a4710e26f302e4c90a623830f9f7515
data/CHANGELOG.md CHANGED
@@ -5,6 +5,24 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.3.2] - 2024-12-19
9
+
10
+ ### Added
11
+
12
+ - **Kebab-case attribute support**: Support for HTML-style kebab-case attributes in addition to snake_case
13
+ - `<Button data-test-id="value" />` converts to `data_test_id: "value"`
14
+ - `<Button aria-label="Click me" />` converts to `aria_label: "Click me"`
15
+ - Works with boolean attributes: `<Button data-disabled aria-hidden />`
16
+ - Supports Ruby expressions: `<Button data-user-id={@user.id} />`
17
+ - Fully backward compatible with existing snake_case attributes
18
+ - Automatically converts kebab-case to snake_case for Ruby compatibility
19
+
20
+ ## [0.3.1] - 2024-12-19
21
+
22
+ ### Fixed
23
+
24
+ - **Robust attribute parsing**: Fixed a bug where complex or nested Ruby expressions (e.g., arrays or hashes with nested braces) in attribute values could cause parsing errors or incorrect output. The attribute parser is now fully robust and handles any valid Ruby expression inside `{...}` for both component and slot attributes.
25
+
8
26
  ## [0.3.0] - 2024-12-19
9
27
 
10
28
  ### Added
data/README.md CHANGED
@@ -64,6 +64,17 @@ $ bundle install
64
64
 
65
65
  The template handler will be automatically registered for `.evc` files.
66
66
 
67
+ ## Syntax Highlighting
68
+
69
+ For the best development experience with EVC files, install the [EVC Language Support](https://github.com/senordelaflor/evc-language-support) extension for VS Code. This extension provides:
70
+
71
+ - **Syntax highlighting** for ERB tags (`<% %>`, `<%= %>`, `<%# %>`)
72
+ - **JSX-like attribute syntax** support (`prop={value}`)
73
+ - **Nested bracket matching** for arrays and hashes
74
+ - **HTML tag completion** via Emmet
75
+ - **Auto-closing pairs** for brackets and ERB tags
76
+ - **Proper folding** for ERB blocks
77
+
67
78
  ## Usage
68
79
 
69
80
  ### Basic Components
@@ -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+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|\{([^}]*)\}))?/
16
+ ATTRIBUTE_REGEX = /([a-zA-Z0-9_-]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|\{([^}]*)\}))?/
17
17
 
18
18
  # Cache for compiled templates
19
19
  @template_cache = {}
@@ -274,6 +274,12 @@ module EvcRails
274
274
  name
275
275
  end
276
276
 
277
+ def normalize_attribute_name(attribute_name)
278
+ # Convert dasherized attributes to snake_case for Ruby compatibility
279
+ # e.g., "data-test-id" -> "data_test_id"
280
+ attribute_name.gsub("-", "_")
281
+ end
282
+
277
283
  def parse_attributes(attributes_str, attribute_regex = ATTRIBUTE_REGEX)
278
284
  as_variable = nil
279
285
  # Find and remove the `as` attribute, storing its value.
@@ -290,9 +296,9 @@ module EvcRails
290
296
  str = "" if str.nil?
291
297
  break if str.empty?
292
298
  # Match key
293
- break unless str =~ /\A(\w+)/
299
+ break unless str =~ /\A([a-zA-Z0-9_-]+)/
294
300
 
295
- key = ::Regexp.last_match(1)
301
+ key = normalize_attribute_name(::Regexp.last_match(1))
296
302
  str = str[::Regexp.last_match(0).length..-1]
297
303
  str = "" if str.nil?
298
304
  str.lstrip!
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EvcRails
4
- VERSION = "0.3.1"
4
+ VERSION = "0.3.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.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - scttymn