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 +4 -4
- data/lib/evc_rails/template_handler.rb +20 -11
- data/lib/evc_rails/version.rb +1 -1
- 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: 9b8286c7a2de504f1e3320186e144fbeadd0c36cf2b0e56b7c2a677994d3ff80
|
4
|
+
data.tar.gz: a03f8ac74485749cf933bab0d0fb3abe16e042c41ba065fd6f259d2379a58225
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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 !=
|
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 </#{
|
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.
|
data/lib/evc_rails/version.rb
CHANGED