Herb: Implement Action View Helper Registry#1611
Merged
Conversation
There was a problem hiding this comment.
CodeQL found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.
9eae332 to
c25e3ac
Compare
9607ba5 to
70a3f77
Compare
73f2627 to
d2b5a27
Compare
b3e5fd9 to
8354968
Compare
commit: |
🌿 Interactive Playground and Documentation PreviewA preview deployment has been built for this pull request. Try out the changes live in the interactive playground: 🌱 Grown from commit ✅ Preview deployment has been cleaned up. |
8354968 to
050f94a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces a comprehensive Action View Helper Registry, a single source of truth for all Rails view helper methods, generated across C, TypeScript, Ruby, Java, and Rust from individual YAML configuration files.
Motivation
Previously, metadata about Action View helpers (signatures, documentation URLs, tag mappings, options) was scattered across multiple hand-written files:
image_tag.c,link_to.c, etc.) with hardcoded detect/extract functionsaction_view_helpers.ts)Adding or modifying a helper required touching 3+ files across multiple languages. There was no central place to answer "what helpers exist?" or "what does this helper produce?"
Additionally, for the precompilation and reactivity it is important to understand which built-in helpers are being used in a template, so that we can either handle it accordingly, or warn/error when we see the usage of one of these helpers in the compilation step for reactive templates.
What changed
Registry data (
config/action_view_helpers/)YAML files organized by gem and module:
Code generation (
templates/template.rb)New classes (
HelperType,HelperTagInfo,HelperContent,HelperSpecialBehavior, etc.) parse the YAML and feed 8 ERB templates that generate:helper_registry.h/c(type enum, registry struct, lookup functions) +generated_handlers.c/h(detect, extract_tag_name, extract_content functions for all supported helpers)action-view-helpers.ts(enum, interfaces, registry maps, scoped query functions)helper_registry.rb(typed classes, registry module with lookup methods, scoped queries)HelperRegistry.java(enum, entry class, static registry)action_view_helpers.rs(enum, structs, lookup functions)Generated C handlers replace hand-written code
6 of 7 supported helpers now have their
detect,extract_tag_name,extract_content, andsupports_blockfunctions generated from YAML instead of hand-written. The individual.cfiles(
image_tag.c,turbo_frame_tag.c, etc.) were stripped down to only their unique helper-specific functions (src extraction, path wrapping, id wrapping). Onlylink_to.cretains its hand-written transformdue to complex href/route-helper logic.
Language server improvements
dom_idinside<%= turbo_frame_tag dom_id(user) do %>showsdom_id's documentationHELPER_BY_SOURCE,HELPERS_BY_TAG_NAME,findPreferredHelperForTag()replace all hardcoded source stringsCleanShot.2026-04-05.at.19.31.21.mp4
Consumer code updates
erb-no-javascript-tag-helper,html-require-script-nonce,a11y-no-autofocus-attributenow use registry lookups instead of hardcoded stringshtml-to-action-view-tag-helperusesfindPreferredHelperForTag()andHELPER_REGISTRYfor tag-to-helper mappinghover_service.tsandrewrite_code_action_service.tsuse registry for all helper resolutionDeleted
javascript/packages/language-server/src/action_view_helpers.tsreplaced by generated@herb-tools/coreexportsrc/analyze/action_view/content_tag.cfully generatedsrc/analyze/action_view/tag.cfully generated