Repository navigation
Bind ActionView view layer into rbgo (require "action_view") - #195
Closed
tannevaled wants to merge 1 commit into
Closed
tannevaled wants to merge 1 commit into
tannevaled wants to merge 1 commit into
Conversation
Bind github.com/go-ruby-actionview/actionview as a native module so
`require "action_view"` works with no .rb file. ActionView::Base is the
view context exposing the pure tag/url/form/text/number helpers
(delegating to the library package functions) alongside the stateful
helpers (button_to, form_tag, form_with, current_page?, render) that
build a fresh library Context per call from the instance configuration.
Surface bound:
- ActiveSupport::SafeBuffer (+ ActionView::OutputBuffer alias) with
escape-on-concat << / concat / safe_concat / + and String#html_safe;
- tag helpers content_tag/tag/token_list/class_names/cdata_section;
- url helpers link_to/mail_to/button_to/current_page?/url_for;
- form_tag-family inputs, select_tag, submit/button, options_for_select,
form_tag, and form_with yielding an ActionView::Helpers::FormBuilder;
- text helpers truncate/pluralize/simple_format/word_wrap/highlight/
excerpt and the eight NumberHelper formatters;
- ActionView::PartialIteration for collection partials.
Seams: URLFor (routes) wires to a Ruby url_for= callable, else the
identity/path default; RenderTemplate wires to a Ruby render_template=
callable, else an inline-ERB default that evaluates the template through
the already-bound go-ruby-erb compiler so <%= %> runs Ruby against the
view context (binding-scoped locals + @Ivars via the ivarTable seam).
#render stays an ordinary dispatchable method so a later actionpack/
actionmailer binding renders a view by sending :render to a Base.
100% coverage of the new files; full internal/vm + internal/object
suites green; gofmt/vet clean; builds on all six 64-bit arches and under
the closed-world build tag.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Contributor
Author
|
Superseded by the wave-2 consolidation PR (single merge onto main; shared builtins/require/object_model/vm/arith/digest_bind). Work preserved verbatim; branch kept for reference. |
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.
Binds
github.com/go-ruby-actionview/actionview(orggo-ruby-actionview, repoactionview, pinned@main=0e293ee) as a native module sorequire "action_view"resolves with no.rbfile. This is the render bridge later actionpack/actionmailer bindings wire to.Surface bound
ActiveSupport::SafeBuffer(aliasedActionView::OutputBuffer) — html-safe string with escape-on-concat<</concat/safe_concat/+/include?, plusString#html_safe/#html_safe?.ActionView::Baseview context:content_tag(positional + block),tag,token_list/class_names,cdata_section;link_to(positional + block),mail_to,button_to,current_page?,url_for;text_field_tag/password_field_tag/hidden_field_tag/text_area_tag/check_box_tag/radio_button_tag/select_tag/label_tag/submit_tag/button_tag,options_for_select,form_tag;form_withyielding anActionView::Helpers::FormBuilder(text_field,password_field,hidden_field,text_area,label,check_box,radio_button,select,submit,object_name/field_name/field_id);truncate,pluralize,simple_format,word_wrap,highlight,excerpt;number_to_currency,number_with_delimiter/number_to_delimited,number_with_precision/number_to_rounded,number_to_percentage,number_to_human_size,number_to_human.ActionView::PartialIteration(index/size/first?/last?) for collection partials.All observable output (tag_options rendering,
user[name]/user_nameconventions, currency/number formatting, SafeBuffer escaping) is produced by the pure-Go library; this PR is the argument mapping + result wrapping.Seams
URLFor(routes) — wires to a Rubyurl_for=callable when set, else the identity/path default.RenderTemplate— wires to a Rubyrender_template=callable when set (the hook actionpack overrides with its own resolver), else an inline-ERB default that compiles the template through the already-bound go-ruby-erb compiler (erubi mode) and evaluates it with the render locals bound andself= the Base, so<%= %>runs Ruby (helpers dispatch,@ivarsresolve via a newivarTablecase, collection_counter/_iterationlocals bound). Split into open/closed build variants like the Sinatra erb helper.#renderstays a plain dispatchable method — a later actionpack/actionmailer binding renders a view by sending:renderto aBasewhoserender_templatecallable is wired, so the whole pipeline funnels through one method.Wiring
providedFeatures:action_view+actionview.registerActionView()runs afterregisterActiveSupport(SafeBuffer nests underActiveSupport) and after the bootstrap ERB/Erubi registration.classOf: cases for*SafeBufferVal/*ActionViewBase/*AVPartialIter/*FormBuilderVal;ivarTable: case for*ActionViewBase;arithoperator fast-path:+on*SafeBufferValdispatches as a method (so views build markup withf.label + f.text_field).Verification
actionview*.gofiles (51 functions), including the SafeBuffer escaping, every helper family, theURLFor/RenderTemplateseam branches (Ruby-callable + default), and the three inline-render error branches (fault-injected erb-compile / parse / compile failures).internal/vm+internal/objectsuites green;gofmt -lclean;go vetclean; builds on all six 64-bit arches (amd64/arm64/riscv64/loong64/ppc64le/s390x) and under-tags rbgo_closed.🤖 Generated with Claude Code