-
Notifications
You must be signed in to change notification settings - Fork 1
Closed
Description
Problem
The AttributesRenderer#parse_name method converts all underscores to hyphens:
private def parse_name(name) : String
name.to_s.gsub("_", "-")
end
This works well for standard HTML attributes (e.g., data_foo_bar → data-foo-bar), but breaks frameworks that use double underscores as meaningful syntax.
For example, https://data-star.dev uses double underscores for action modifiers:
- `data-on:click__prevent` - prevents default behavior
- `data-on:click__debounce_500ms` - debounces the action
With the current implementation, "data-on:click__prevent" becomes data-on:click--prevent, which is invalid.
## Current Workaround
I'm monkey-patching parse_name in my adapter to preserve double underscores:
```crystal
module Blueprint::HTML::AttributesRenderer
private def parse_name(name) : String
result = name.to_s.gsub("__", "\x00\x01\x00")
result = result.gsub("_", "-")
result.gsub("\x00\x01\x00", "__")
end
endSuggested Solutions
- Preserve double underscores by default - Change parse_name to only convert single underscores, leaving __ intact.
- Make the conversion configurable - Allow users to customize or disable the underscore-to-hyphen conversion.
Would either of these approaches be acceptable? Happy to submit a PR if so.
Metadata
Metadata
Assignees
Labels
No labels