Skip to content

Ruby: Analyze and resolve Action View render calls#1663

Merged
marcoroth merged 5 commits intomainfrom
actionview-render-graph
Apr 21, 2026
Merged

Ruby: Analyze and resolve Action View render calls#1663
marcoroth merged 5 commits intomainfrom
actionview-render-graph

Conversation

@marcoroth
Copy link
Copy Markdown
Owner

@marcoroth marcoroth commented Apr 21, 2026

This pull request introduces ActionView render call analysis, a system that statically traces render calls across ERB templates to build dependency graphs, detect unresolved partials, find unused partials, and verify full resolvability of entry points.

Motivation

Herb needs to understand the render dependencies between templates to support runtime reactivity, Herb dev server patches, and for potential compile-time optimizations.

When a partial changes (whether its file on disk during development or its underlying state at runtime) we need to know which entry points are affected and may need re-rendering. The render graph gives us that reverse lookup, enabling the dev server to notify the right clients and future reactive rendering to trace exactly which templates to update.

Beyond reactivity, static resolution of render calls is a prerequisite for compile-time partial inlining (see #654). If we can prove at compile time that a render call resolves unambiguously to a single partial file, we can eliminate the expensive runtime file lookup entirely either by inlining the partial's content directly or by rewriting the call to ActionView's internal compiled method.

The fully_resolvable? API provides exactly that guarantee: it walks the full render tree and confirms there are no dynamic or unresolved gaps that would make such optimizations unsafe.

Example Output

bundle exec herb actionview graph app/views/profiles/show.html.erb

CleanShot 2026-04-21 at 10 30 36@2x

bundle exec herb actionview graph app/views/profiles/_header.html.erb

CleanShot 2026-04-21 at 10 31 01@2x

bundle exec herb actionview check

CleanShot 2026-04-21 at 11 08 36@2x

Ruby API

analyzer = Herb::ActionView::RenderAnalyzer.new("/path/to/project")

result = analyzer.analyze
result.unresolved  
result.unused    
result.issues?  

analyzer.fully_resolvable?("app/views/posts/show.html.erb") # => true/false

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Apr 21, 2026

npx https://pkg.pr.new/@herb-tools/formatter@1663
npx https://pkg.pr.new/@herb-tools/language-server@1663
npx https://pkg.pr.new/@herb-tools/linter@1663

commit: fa509f6

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 21, 2026

🌿 Interactive Playground and Documentation Preview

A preview deployment has been built for this pull request. Try out the changes live in the interactive playground:


🌱 Grown from commit fa509f6


✅ Preview deployment has been cleaned up.

@marcoroth marcoroth added this to the v1.0.0 milestone Apr 21, 2026
@marcoroth marcoroth merged commit bf9f843 into main Apr 21, 2026
32 checks passed
@marcoroth marcoroth deleted the actionview-render-graph branch April 21, 2026 02:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant