Skip to content

Evaluate static translation interpolations once in source order - #982

Open
OskarEichler wants to merge 1 commit into
slim-template:mainfrom
OskarEichler:codex/static-translation-capture-once
Open

Evaluate static translation interpolations once in source order#982
OskarEichler wants to merge 1 commit into
slim-template:mainfrom
OskarEichler:codex/static-translation-capture-once

Conversation

@OskarEichler

Copy link
Copy Markdown

Summary

Evaluate interpolations once, in source order, when using static translation. Capture their rendered values before substituting translated placeholders, matching the existing dynamic translation semantics.

Reproduction

For p #{next_value}, let the translator repeat %1 as %1 %1, and let next_value increment a counter. Static mode currently renders <p>1 2</p> while dynamic mode renders <p>1 1</p>. Reordering or dropping translated placeholders likewise reorders or omits expression evaluation in static mode. After this patch both modes evaluate source expressions once in source order.

Verification

  • Unmodified core/plugin suites: 415 runs / 650 assertions passing on Ruby 3.2.11 and 4.0.6; Rails integration 15 runs / 36 assertions passing on each.
  • 1,200 focused checks per Ruby cover identity/repeated/reordered/omitted placeholders, expression count/order, escaped values and exact static/dynamic output equivalence.
  • Syntax passes; comparative Lint introduces no new offenses. No test files changed.

Compatibility / limitations

No API removal or dependency upgrade. Behavior change: interpolation side effects now happen once in source order, including when a translation omits a placeholder. Applications relying on repeated/skipped/reordered evaluation in static mode will observe the corrected behavior. Translation itself still happens at compile time in static mode.

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