Skip to content

Copy embedded engine options before supplying defaults - #979

Open
OskarEichler wants to merge 1 commit into
slim-template:mainfrom
OskarEichler:codex/embedded-option-ownership
Open

OskarEichler wants to merge 1 commit into
slim-template:mainfrom
OskarEichler:codex/embedded-option-ownership

Conversation

@OskarEichler

Copy link
Copy Markdown

Summary

Copy an embedded engine's option hash before adding the default encoding. Rendering should not mutate the caller's options; frozen configuration should work too.

Reproduction

require 'slim'
options = { auto_ids: false }.freeze
Slim::Template.new(markdown: options) { "markdown:\n  # Header" }.render

With Kramdown available, this currently raises FrozenError while assigning default_encoding. With mutable options it silently adds a key to the caller's hash. The patch renders the same output and leaves both frozen and mutable input unchanged. Existing explicit encoding/default behavior is retained.

Verification

  • Unmodified upstream core/plugin suites: 415 runs / 650 assertions, zero failures/errors/skips on Ruby 3.2.11 and 4.0.6.
  • Existing Rails integration: 15 runs / 36 assertions passing on each, Rails 8.1.3.1 / Temple 0.10.7 / Tilt 2.9.0.
  • 720 focused checks per Ruby across frozen/mutable hashes, explicit/missing/nil/false encodings and Markdown options.
  • Ruby syntax passes; comparative Lint introduces no new offenses (existing baseline offenses retained). No test files changed.

Compatibility / limitations

No API removal, dependency upgrade or intended breaking change. This is a shallow copy because only the top-level default is assigned. Kramdown/Asciidoctor and the existing suites were exercised; not every optional Tilt engine or Ruby implementation.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant