Skip to content

Adjust Localize helpers#6572

Merged
david-poindexter merged 2 commits intodnnsoftware:developfrom
bdukes:localize-helpers
Jun 3, 2025
Merged

Adjust Localize helpers#6572
david-poindexter merged 2 commits intodnnsoftware:developfrom
bdukes:localize-helpers

Conversation

@bdukes
Copy link
Copy Markdown
Contributor

@bdukes bdukes commented Jun 2, 2025

Summary

PortalModuleBase exposes two helpers, LocalizeString and LocalizeSafeJsString. I propose that these are deprecated and replaced with three helpers, LocalizeText, LocalizeHtml, and LocalizeJsString, which use the IHtmlString abstraction to provide proper encoding. This will allow markup to more easily transition to using the safer <%: something %> code placeholders (colloquially, bee-stings) instead of <%= something %>.

Fixes #6571

This PR also adds the following static helper methods:

  • IHtmlString HtmlUtils.JavaScriptStringEncode(string)
  • IHtmlString PageBase.JavaScriptStringEncode(string)
  • IHtmlString UserControlBase.JavaScriptStringEncode(string)
  • IHtmlString HtmlUtils.JavaScriptStringEncode(string, bool)
  • IHtmlString PageBase.JavaScriptStringEncode(string, bool)
  • IHtmlString UserControlBase.JavaScriptStringEncode(string, bool)

Finally, due to marking some members as obsolete, this PR also replaces usages of LocalizeString with LocalizeText in projects where obsolete usage is a compilation error. In those controls, I also adjusted the frontend markup to use <%: bee stings.

@bdukes bdukes added this to the 10.0.2 milestone Jun 2, 2025
bdukes added 2 commits June 2, 2025 16:28
Also update related markup files to use encoding bee-stings
@bdukes bdukes force-pushed the localize-helpers branch from 9e2f6a8 to 6ab91ca Compare June 2, 2025 21:28
Copy link
Copy Markdown
Contributor

@valadas valadas left a comment

Choose a reason for hiding this comment

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

Awesome!

Copy link
Copy Markdown
Contributor

@david-poindexter david-poindexter left a comment

Choose a reason for hiding this comment

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

Saweet!

@david-poindexter david-poindexter merged commit e68b332 into dnnsoftware:develop Jun 3, 2025
3 checks passed
@david-poindexter david-poindexter deleted the localize-helpers branch June 3, 2025 06:03
@valadas valadas modified the milestones: 10.0.2, 10.1.0 Jul 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Enhancement]: Use IHtmlString in more places

3 participants