evc_rails 0.1.1 → 0.1.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: a7fda15b180ea02549511ff7aa2f1a51071ef8cce0fbf9721c92cc8fe4b6f605
4
- data.tar.gz: 03ab565adcff81843d342152c4631c22124ee01d820e8a007a590afea3792347
3
+ metadata.gz: 9b8286c7a2de504f1e3320186e144fbeadd0c36cf2b0e56b7c2a677994d3ff80
4
+ data.tar.gz: a03f8ac74485749cf933bab0d0fb3abe16e042c41ba065fd6f259d2379a58225
5
5
  SHA512:
6
- metadata.gz: c1b7c0694278f7bffbf73b23423f14ca96f993cdfd0f19fe230ce52014405d8f1221f0ff3922c9ae7fab2e889832d1de480b0465b875cfcb4cd6ad26c012fd34
7
- data.tar.gz: 24c79d6ba0ac68acea62831ee0043bfb175ac05a3aab97cbe641b503258dfb4becabc21cc72b7f2b03bffdd8d68a0d88902dd9e82d79101e0c876cd28654f285
6
+ metadata.gz: 9f1256d0f4b2d3ae9d9ac59182dab66c32898f6294e739d23819fc8c590e935f8c2ac5f27a3d5622e50aa5e4657af7618fe8b6bfe97da5baaacb0b296a3d0de3
7
+ data.tar.gz: f6284a6a2d33cbbffa09485895cfbd8b5a9b680073565281b95bdbf32caeb599254daece8fe837e13e1c2f96f3eb4f6b2731be6e1a6ea75cb69a2eb5b07399dc
@@ -74,6 +74,18 @@ module EvcRails
74
74
  @component_class_memo = {}
75
75
  end
76
76
 
77
+ # Helper method to determine the full component class name
78
+ def resolve_component_class_name(tag_name)
79
+ if tag_name.include?("::")
80
+ # For namespaced components, just append Component
81
+ "#{tag_name}Component"
82
+ elsif tag_name.end_with?("Component")
83
+ tag_name
84
+ else
85
+ "#{tag_name}Component"
86
+ end
87
+ end
88
+
77
89
  # Processes the .evc template source, converting custom tags into Rails View Component render calls.
78
90
  # This method is recursive to handle nested components.
79
91
  def process_template(source, template)
@@ -98,15 +110,7 @@ module EvcRails
98
110
  attributes_str = match[3].strip
99
111
 
100
112
  # Determine the full component class name
101
- # Handle both namespaced (UI::Button) and non-namespaced (Button) components
102
- component_class_name = if tag_name.include?("::")
103
- # For namespaced components, just append Component
104
- "#{tag_name}Component"
105
- elsif tag_name.end_with?("Component")
106
- tag_name
107
- else
108
- "#{tag_name}Component"
109
- end
113
+ component_class_name = resolve_component_class_name(tag_name)
110
114
 
111
115
  # Validate if the component class exists using memoization.
112
116
  # The component class will only be constantized once per unique class name
@@ -165,10 +169,15 @@ module EvcRails
165
169
  # Pop the corresponding opening tag from the stack
166
170
  component_class_name, render_params_str, start_pos = stack.pop
167
171
 
172
+ # Apply the same transformation to the closing tag name for comparison
173
+ expected_closing_component_name = resolve_component_class_name(closing_tag_name)
174
+
168
175
  # Check for mismatched tags (e.g., <div></p>)
169
- if component_class_name != closing_tag_name
176
+ if component_class_name != expected_closing_component_name
177
+ # Extract the original tag name from the component class name for the error message
178
+ expected_tag_name = component_class_name.gsub(/Component$/, "")
170
179
  raise ArgumentError,
171
- "Mismatched tags: expected </#{component_class_name}>, got </#{closing_tag_name}> in template #{template.identifier}"
180
+ "Mismatched tags: expected </#{expected_tag_name}>, got </#{closing_tag_name}> in template #{template.identifier}"
172
181
  end
173
182
 
174
183
  # Recursively process the content between the opening and closing tags.
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EvcRails
4
- VERSION = "0.1.1"
4
+ VERSION = "0.1.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.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - scttymn