← Back to Issue

Allow to configure ERB options through ActionView::Base

From uloza+hey@proton.me · original ↗ · unsubscribe

The ActionView::Template::Handlers::ERB class is now private API. Applications that used to configure ERB options such as escape_ignore_list now need to do this on the ActionView::Base class or on the railtie config.action_view configuration.


Allow to configure ERB options through `ActionView::Base` by Edouard-chin · Pull Request #58359 · rails/rails · GitHub

Skip to content

Sign in

Appearance settings

Search/

Sign in

Sign up

Appearance settings

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert

Uh oh!

There was an error while loading. Please reload this page.

rails / rails Public

Additional navigation options

Allow to configure ERB options through ActionView::Base - #58359

#58359

Merged

gmcgibbon merged 2 commits into

rails:mainrails/rails:mainfrom

Shopify:ec-doc-for-erbShopify/rails:ec-doc-for-erbCopy head branch name to clipboard

Aug 7, 2026

ConversationCommits2 (2)ChecksFiles changed

Merged

##

Allow to configure ERB options through ActionView::Base#58359

gmcgibbon merged 2 commits into

rails:mainrails/rails:mainfrom

Shopify:ec-doc-for-erbShopify/rails:ec-doc-for-erbCopy head branch name to clipboard

Conversation

@Edouard-chin

###

@Edouard-chinEdouard-chin commented Aug 3, 2026 •

edited

Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link

Copy Markdown

Member

Motivation / Background

This Pull Request has been created because in 970bf38 we added a :nodoc: to officialy not document AV::Template::Handlers::ERB, but some applications were legitimatelly referecing that class to store documented configuration.

Additional information

This patch allows to configure all options from the ERB handlers inside ActionView::Base (or config.action_view.<setting>). This was already possible for erb_trim_mode.

Also added new tests to ensure the behaviour since none existed.

Checklist

Before submitting the PR make sure the following are checked:

  • This Pull Request is related to one change. Unrelated changes should be opened in separate PRs.
  • Commit message has a detailed description of what changed and why. If this PR fixes a related issue include it in the commit message. Ex: [Fix #issue-number]
  • Tests are added or updated if you fix a bug or add a feature.
  • CHANGELOG files are updated for the changed libraries if there is a behavior change or additional feature. Minor bug fixes and documentation changes should not be included.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions @github-actions github-actions Bot added docs actionview labels Aug 3, 2026

@Edouard-chin

Edouard-chin force-pushed the ec-doc-for-erb branch from f24e83d to 99dee30 Compare August 3, 2026 14:09

etiennebarrie

etiennebarrie reviewed Aug 3, 2026

View reviewed changes

###

@etiennebarrieetiennebarrie left a comment

Copy link

Copy Markdown

Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality Hide comment

FWIW the documents weren’t working: https://api.rubyonrails.org/v8.1/classes/ActionView/Template/Handlers/ERB.html

I don’t know if we ever had a patch to support class_attribute but I can’t even find an old version of the documentation that showed these.

But it’s good to make them public I think 👍

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

👍 1 Edouard-chin reacted with thumbs up emoji

All reactions

  • 👍 1 reaction

Comment thread actionview/lib/action_view/base.rb Outdated Show resolved Hide resolved

Uh oh!

There was an error while loading. Please reload this page.

@Edouard-chin

Edouard-chin force-pushed the ec-doc-for-erb branch from 99dee30 to ca374b9 Compare August 3, 2026 14:20

etiennebarrie

etiennebarrie reviewed Aug 3, 2026

View reviewed changes

###

@etiennebarrieetiennebarrie left a comment

Copy link

Copy Markdown

Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality Hide comment

oh I found this: https://api.rubyonrails.org/v3.0/classes/ActionView/Template/Handlers/ERB.html#method-c-erb_trim_mode

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

Comment thread actionview/lib/action_view/base.rb Outdated Show resolved Hide resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread actionview/lib/action_view/base.rb Outdated Show resolved Hide resolved

Uh oh!

There was an error while loading. Please reload this page.

@Edouard-chin

Edouard-chin force-pushed the ec-doc-for-erb branch from ca374b9 to 477a080 Compare August 3, 2026 15:16

@Edouard-chin Edouard-chin mentioned this pull request Aug 3, 2026

Freeze ActionView::Template::Handlers::ERB.escape_ignore_list #58362

Merged

4 tasks

@hmcguire-shopify

###

hmcguire-shopify commented Aug 4, 2026 •

edited

Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link

Copy Markdown

Contributor

but some applications were legitimatelly referecing that class to store documented configuration.

If we’re acknowledging that the class was actually used, shouldn’t we add deprecations for the existing accessors to suggest the using the new ones?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Edouard-chin

###

Edouard-chin commented Aug 4, 2026 •

edited

Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link

Copy Markdown

Member Author

Yeah it’s a bit of a unusual situation because we aren’t deprecating any code per se (that’s why I made sure the CHANGELOG didn’t mention the word deprecation), just marking it no doc. Have to find a way to prevent triggering a deprecation when those get used internally.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

gmcgibbon pushed a commit that referenced this pull request Aug 4, 2026

@Edouard-chin

[Freeze ActionView::Template::Handlers::ERB.escape_ignore_list:](/rails/rails/commit/6afe70b8116de7292d1b47e906670bd3644dd9d7 "Freeze ActionView::Template::Handlers::ERB.escape_ignore_list: - I'd like to access this array inside a Ractor. It's not possible now because the array isn't frozen. This configuration is Public API (even thouh the surrouding class was recently changed to be nodoc, but the doc is being retroduced in #58359) While it's possible that this array gets mutated at runtime, it's really unlikely, and it would be inconsistent. A quick GitHub codesearch confirms that the few libraries/app that modifies this config does that at boot time.") …

[6afe70b](/rails/rails/commit/6afe70b8116de7292d1b47e906670bd3644dd9d7)

- I’d like to access this array inside a Ractor. It’s not possible now because the array isn’t frozen.

This configuration is Public API (even thouh the surrouding class was recently changed to be nodoc, but the doc is being retroduced in #58359)

While it’s possible that this array gets mutated at runtime, it’s really unlikely, and it would be inconsistent. A quick GitHub codesearch confirms that the few libraries/app that modifies this config does that at boot time.

gmcgibbon

gmcgibbon reviewed Aug 4, 2026

View reviewed changes

###

@gmcgibbongmcgibbon left a comment

Copy link

Copy Markdown

Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality Hide comment

As per our discussion in #58362, I think we need to use ActiveSupport::Ractors.make_shareable on the value now that it can be set via config. Apps and dependencies may not have frozen_string_literal enabled, so it is unsafe to assume that they’re shovel on frozen strings IMO.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

Comment thread actionview/lib/action_view/base.rb Outdated Show resolved Hide resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread guides/source/configuring.md Outdated Show resolved Hide resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread guides/source/configuring.md Outdated Show resolved Hide resolved

Uh oh!

There was an error while loading. Please reload this page.

@Edouard-chin

###

Edouard-chin commented Aug 4, 2026

Copy link

Copy Markdown

Member Author

Apps and dependencies may not have frozen_string_literal enabled,

I don’t think that this is a framework concern. I’m happy to do the change, but I find that we are starting to introduce inconsistency on our approach. E.g. we already merged a few similar patches without taking into account that apps/libraries may use unfrozen strings 0e2dc80b9e1

rails/actionpack/lib/action_dispatch/railtie.rb

Lines 94 to 97 in 817fc2a

ActionDispatch::ExceptionWrapper.rescue_responses = ActionDispatch::ExceptionWrapper.rescue_responses.merge(config.action_dispatch.rescue_responses).freeze

ActionDispatch::ExceptionWrapper.rescue_templates = ActionDispatch::ExceptionWrapper.rescue_templates.merge(config.action_dispatch.rescue_templates).freeze

ActionDispatch::ExceptionWrapper.wrapper_exceptions = (ActionDispatch::ExceptionWrapper.wrapper_exceptions config.action_dispatch.wrapper_exceptions).freeze
ActionDispatch::ExceptionWrapper.silent_exceptions = (ActionDispatch::ExceptionWrapper.silent_exceptions config.action_dispatch.silent_exceptions).freeze

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@gmcgibbon

###

gmcgibbon commented Aug 5, 2026 •

edited

Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link

Copy Markdown

Member

I think it is, and I don’t think #57483 was the right choice. That’s why I started in on #57852 but its much harder to write a patch that “freezes everything” when we’re still trying to figure out exactly what we need to freeze / make shareable. Is the apprehension because of performance? It seemed like we used make_shareable recently in #58374 but reverted once we realized the objects were recursively frozen by default. Maybe we can get a second opinion?

👍 1 Edouard-chin reacted with thumbs up emoji

All reactions

  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Edouard-chin

Edouard-chin force-pushed the ec-doc-for-erb branch from 36f9698 to 211f448 Compare August 5, 2026 23:21

@Edouard-chin

[Allow to configure ERB options through `ActionView::Base`:](/rails/rails/pull/58359/commits/444665776523a939c1c099821760ced3b728cfc8 "Allow to configure ERB options through `ActionView::Base`: - ### Problem In #970bf380fe8 we added a :nodoc: to official not document AV::Template::Handlers::ERB, but some applications were legitimatelly referecing that class to store documented configuration. ### Solution This patch allows to configure all options from the ERB handlers inside ActionView::Base (or `config.action_view.<setting>`). This was already possible for `erb_trim_mode`. Also added new tests to ensure the behaviour since none existed.") …

[4446657](/rails/rails/pull/58359/commits/444665776523a939c1c099821760ced3b728cfc8)

- ### Problem

In #970bf380fe8 we added a :nodoc: to official not document AV::Template::Handlers::ERB, but some applications were legitimatelly referecing that class to store documented configuration.

### Solution

This patch allows to configure all options from the ERB handlers inside ActionView::Base (or `config.action_view.\`). This was already possible for \`erb\_trim\_mode\`.

Also added new tests to ensure the behaviour since none existed.

@Edouard-chin

Edouard-chin force-pushed the ec-doc-for-erb branch from 211f448 to 72b5860 Compare August 7, 2026 17:51

@gmcgibbon

gmcgibbon enabled auto-merge August 7, 2026 17:53

gmcgibbon

gmcgibbon approved these changes Aug 7, 2026

View reviewed changes

@Edouard-chin

Edouard-chin force-pushed the ec-doc-for-erb branch from 72b5860 to f2c7e34 Compare August 7, 2026 17:53

@Edouard-chin

[Use `Ractor#make_shareable` instead of freeze:](/rails/rails/pull/58359/commits/d0743addea8d13187ae5f043c1d2fa1d879508f3 "Use `Ractor#make_shareable` instead of freeze: - There is a concern that users may be adding unfrozen string to that configuration so we want to ancipate and freeze things for them.") …

[d0743ad](/rails/rails/pull/58359/commits/d0743addea8d13187ae5f043c1d2fa1d879508f3)

- There is a concern that users may be adding unfrozen string to that configuration so we want to ancipate and freeze things for them.

@Edouard-chin

Edouard-chin force-pushed the ec-doc-for-erb branch from f2c7e34 to d0743ad Compare August 7, 2026 18:03

@github-actions github-actions Bot added the railties label Aug 7, 2026

Hide details View details

@gmcgibbon

gmcgibbon merged commit 0e8569c into rails:main Aug 7, 2026

5 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@gmcgibbon

gmcgibbon deleted the ec-doc-for-erb branch August 7, 2026 18:10

@skipkayhil skipkayhil added the Ractor Support Issues and pull requests regarding Ractor support label Aug 14, 2026

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

### Reviewers

@gmcgibbongmcgibbon gmcgibbon approved these changes

+1 more reviewer

@etiennebarrieetiennebarrie etiennebarrie left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

actionview docs Ractor Support Issues and pull requests regarding Ractor support railties

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@Edouard-chin@hmcguire-shopify @gmcgibbon @etiennebarrie @skipkayhil

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.

© 2026 GitHub, Inc.

You can’t perform that action at this time.

Highlights & notes

    Notes