-
Fix the debug page for errors raised in view templates on Ruby 4.1.
Ruby 4.1 builds prism into the interpreter as
Ruby::Prism, and error_highlight accepts only its nodes.ActionView::Template#spotnow usesRuby::Prismwhen it is available instead of the prism gem.Yasuo Honda
-
Allow setting
config.action_view.erb_implementationto:herbto compile HTML+ERB templates through Herb.With
config.load_defaults 8.2, templates with the HTML format compile through Herb, an ERB implementation that parses HTML+ERB and reports structural problems, such as an unclosed tag, at compile time with their template location. Valid templates render the same output as with Erubi. All other template formats keep compiling through Erubi.Set
config.action_view.erb_implementationto:erubito continue to compile every template through Erubi.Marco Roth
-
Add a
herb:checkrake task to verify that the application's HTML+ERB templates compile through Herb.The task lists every template Herb rejects with its path and error, and exits with a non-zero status when there are any.
Marco Roth
-
Allow
translate's (andt's)scope:option to be resolved relative to the current template when it starts with a period, mirroring the existing behavior for the key argument.Calling
translate("bar", scope: ".foo")fromposts/index.html.erbis now equivalent to callingtranslate("posts.index.foo.bar").Ben Sheldon
-
Join an
Array:acceptoption with commas infile_field_tag.Previously, passing
accept: ["image/png", "image/gif"]renderedaccept="image/png image/gif", while the HTMLacceptattribute is a comma-separated list. It now rendersaccept="image/png,image/gif", matching the object-basedfile_field.Kenta Ishizaki
-
current_page?matches HTTP QUERY requests RFC 10008) withmethod: :query. The defaultmethod: :getdeliberately does not match QUERY.Jeremy Daer
-
Configuring ERB options is now to be made on the
::ActionView::Baseclass.The
ActionView::Template::Handlers::ERBclass is now private API. Applications that used to configure ERB options such asescape_ignore_listnow need to do this on theActionView::Baseclass or on the railtieconfig.action_viewconfiguration.ActionView::Base.erb_trim_mode = nil ActionView::Base.erb_implementation = ERB ActionView::Base.escape_ignore_list = ["text/csv"] ActionView::Base.strip_trailing_newlines = falseEdouard Chin
-
Fix
search_fieldraisingNameErrorwhen passedautosave: true.Hammad Khan
-
Deprecate registering dependency trackers after application initialization.
Calling
ActionView::DependencyTracker.register_trackerafter application initialization will raise a FrozenError in the next version of Rails.Instead, register trackers during application initialization, wrapped in a call to
ActiveSupport.on_load(:action_view)to wait until Action View is available.Étienne Barrié
-
Extract
current_page?,button_to, andlink_tomethods toActionView::Helpers::NavigationHelperSean Doyle
-
Accept
DateandNumericinputs inrelative_time_in_words.Passing a
Dateor aNumericraisedArgumentErrorinstead of returning a distance string, unlikedistance_of_time_in_wordswhich accepts them.Kenta Ishizaki
-
Support endless and beginless ranges in
number_field_tagandrange_field_tag.Previously, passing an endless (
18..) or beginless (..10) range as the:in/:withinoption raisedRangeError. Now an endless range rendersminwithoutmax, and a beginless range rendersmaxwithoutmin, matchingnumber_fieldandrange_field.Kenta Ishizaki
-
Honor an explicit
value:option incolor_field, includingnil.Previously, passing
value: nilwas ignored and the field still pre-filled from the model's stored color. Now an explicitly providedvalue:is honored, and the stored color is only used when novalue:option is given.Kenta Ishizaki
-
Calling
safe_joinin a view no longer fallbacks to the$,global variable.Previously, calling
safe_joinwould use$,by default to separate elements. Ruby has deprecated the usage of setting$,for more than 10 years and its usage insafe_joinwas never documented.If your application relied on this behaviour, make sure to explicitly pass the separator to
safe_joinas the default is nownil(no separation).Edouard Chin
-
Fix
ActionView::TestCase#renderto resetrendered. The behavior was changed when memoization was added in #51093. Now it once again conforms to the documentation.Jeroen Versteeg
-
Fix
FormBuilder#to_partial_pathreturningnilfor subclasses whose name does not end inBuilder.Kenta Ishizaki
-
Fix
collection_radio_buttonsandcollection_check_boxesgenerating a labelforattribute that does not match the inputidwhen a collection value isnil.Kenta Ishizaki
-
Pass render options and block to calls to
#render_inclass Greeting def render_in(view_context, **) if block_given? view_context.render(html: yield) else view_context.render(inline: <<~ERB.strip, **) Hello <%= local_assigns[:name] || "World" %> ERB end end end render(Greeting.new) # => "Hello, World" render(Greeting.new, name: "Local") # => "Hello, Local" render(renderable: Greeting.new, locals: { name: "Local" }) # => "Hello, Local" render(Greeting.new) { "Hello, Block" } # => "Hello, Block"Sean Doyle
-
Add
f.datalisttoFormBuilderExample:
<%= form_with model: @post do |f| %> <%# Wire the input to the datalist using the same derived id: %> <%= f.text_field :country, list: f.field_id(:country, :datalist) %> <%= f.datalist :country, ["Argentina", "Brazil", "Chile"] %> <% end %> Produces: <input list="post_country_datalist" type="text" name="post[country]" id="post_country" /> <datalist id="post_country_datalist"> <option value="Argentina">Argentina</option> <option value="Brazil">Brazil</option> <option value="Chile">Chile</option> </datalist> *Tahsin Hasan* -
Add
datalist_tagto createdatalistform elements.Example:
datalist_tag('countries_datalist', ['Argentina', ['Brazil', { class: 'brazilian_option' }], ['Chile', 'CL', { disabled: true }]], { class: 'sa-countries-sample' }) #=> <datalist id="countries_datalist" class="sa-countries-sample"> <option value="Argentina">Argentina</option> <option value="Brazil" class="brazilian_option">Brazil</option> <option value="CL" disabled="disabled">Chile</option> </datalist>Willian Gustavo Veiga
-
Render
Hashand keyword options as dasherized HTML attributestag. "POST to /clicked", hx: { post: "/clicked", swap: :outerHTML, data: { json: true } } # => <button hx-post="/clicked" hx-swap="outerHTML" hx-data="{"json":true}">POST to /clicked</button>Sean Doyle
-
ViewReloader#deactivateremoves thefile_system_resolver_hookscallback so forked processes that clear reloaders no longer trigger filesystem scans on everyprepend_view_path.Dave Ariens
-
Defer the View watcher build until view paths are actually registered.
Hugo Vacher
-
Skip blank attribute names in tag helpers to avoid generating invalid HTML.
Mike Dalessio
-
Fix tag parameter content being overwritten instead of combined with tag block content. Before
tag.div("Hello ") { "World" }would just return<div>World</div>, now it returns<div>Hello World</div>.DHH
-
Add ability to pass a block when rendering collection. The block will be executed for each rendered element in the collection.
Vincent Robert
-
Add
key:andexpires_in:options undercached:torenderwhen used withcollection:Jarrett Lusso
Please check8-1-stable for previous changes.