Merge branch rel-10.7 with rel-10.6 - #25975
Conversation
…culture-dir Render the `lang` and the `dir` of the current culture in email templates
There was a problem hiding this comment.
Pull request overview
This PR (auto-generated merge from rel-10.7 into rel-10.6) updates the text templating rendering engines (Scriban + Razor) to populate culture-related values into the rendering global context (and to avoid mutating/reusing the caller’s context), then aligns the standard email layout template and documentation accordingly, with accompanying tests.
Changes:
- Add built-in global context keys (
abp_culture,abp_dir) viaTemplateRenderingEngineBase.SetCultureContext(...). - Update Scriban and Razor rendering engines to operate on a copy of
globalContextand set culture context within the rendering scope. - Add/extend tests and documentation + update the standard emailing layout template to use the new context values.
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| framework/test/Volo.Abp.TextTemplating.Scriban.Tests/Volo/Abp/TextTemplating/Scriban/ScribanTestTemplateDefinitionProvider.cs | Registers a new Scriban test template for culture context. |
| framework/test/Volo.Abp.TextTemplating.Scriban.Tests/Volo/Abp/TextTemplating/Scriban/ScribanTemplateRenderingEngine_CultureContext_Tests.cs | Adds Scriban coverage for culture/dir context and context isolation. |
| framework/test/Volo.Abp.TextTemplating.Scriban.Tests/Volo/Abp/TextTemplating/Scriban/SampleTemplates/CultureContext.tpl | Adds Scriban template that consumes abp_culture / abp_dir. |
| framework/test/Volo.Abp.TextTemplating.Razor.Tests/Volo/Abp/TextTemplating/Razor/SampleTemplates/RazorTestTemplates.cs | Adds a Razor test template constant for culture context. |
| framework/test/Volo.Abp.TextTemplating.Razor.Tests/Volo/Abp/TextTemplating/Razor/SampleTemplates/CultureContext.cshtml | Adds Razor template consuming GlobalContext culture/dir values. |
| framework/test/Volo.Abp.TextTemplating.Razor.Tests/Volo/Abp/TextTemplating/Razor/RazorTestTemplateDefinitionProvider.cs | Registers the new Razor culture-context test template. |
| framework/test/Volo.Abp.TextTemplating.Razor.Tests/Volo/Abp/TextTemplating/Razor/RazorTemplateRenderingEngine_CultureContext_Tests.cs | Adds Razor coverage for culture/dir context and context isolation. |
| framework/test/Volo.Abp.Emailing.Tests/Volo/Abp/Emailing/Templates/StandardEmailTemplates_Tests.cs | Adds emailing test ensuring rendered emails declare correct lang/dir. |
| framework/test/Volo.Abp.Emailing.Tests/Volo/Abp/Emailing/AbpEmailingTestModule.cs | Ensures Scriban module is available in emailing tests. |
| framework/test/Volo.Abp.Emailing.Tests/Volo.Abp.Emailing.Tests.csproj | Adds project reference to Scriban templating module for tests. |
| framework/src/Volo.Abp.TextTemplating.Scriban/Volo/Abp/TextTemplating/Scriban/ScribanTemplateRenderingEngine.cs | Copies globalContext and sets culture context before rendering. |
| framework/src/Volo.Abp.TextTemplating.Razor/Volo/Abp/TextTemplating/Razor/RazorTemplateRenderingEngine.cs | Copies globalContext and sets culture context before rendering. |
| framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/TemplateRenderingEngineBase.cs | Introduces abp_culture / abp_dir keys and helpers to set them. |
| framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Templates/Layout.tpl | Updates standard email layout to use culture/dir placeholders. |
| docs/en/framework/infrastructure/text-templating/scriban.md | Documents the new built-in context values for Scriban templates. |
| docs/en/framework/infrastructure/text-templating/razor.md | Documents the new built-in context values for Razor templates. |
| docs/en/framework/infrastructure/emailing.md | Updates emailing docs to mention/use the culture/dir context values. |
Suppressed comments (2)
docs/en/framework/infrastructure/text-templating/razor.md:417
- This Razor example has the same quoting/attribute parsing problem (
@GlobalContext["..."]inside an already-quoted attribute). Wrap the expression in@(...)so Razor treats the inner quotes as part of the C# expression.
<html lang="@GlobalContext["abp_culture"]" dir="@GlobalContext["abp_dir"]">
docs/en/framework/infrastructure/text-templating/razor.md:445
- This Razor snippet uses
@GlobalContext["..."]inside quoted HTML attributes, which breaks Razor parsing. Wrap the indexer expressions in@(...)to make the example compile.
<html lang="@GlobalContext["abp_culture"]" dir="@GlobalContext["abp_dir"]" xmlns="http://www.w3.org/1999/xhtml">
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| @@ -0,0 +1,2 @@ | |||
| @inherits Volo.Abp.TextTemplating.Razor.RazorTemplatePageBase | |||
| <html lang="@GlobalContext["abp_culture"]" dir="@GlobalContext["abp_dir"]"> | |||
| @inherits Volo.Abp.TextTemplating.Razor.RazorTemplatePageBase | ||
| <!DOCTYPE html> | ||
| <html lang="en" xmlns="http://www.w3.org/1999/xhtml"> | ||
| <html lang="@GlobalContext["abp_culture"]" dir="@GlobalContext["abp_dir"]" xmlns="http://www.w3.org/1999/xhtml"> |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## rel-10.7 #25975 +/- ##
============================================
+ Coverage 48.59% 48.77% +0.17%
============================================
Files 3795 3804 +9
Lines 131541 132231 +690
Branches 9979 10027 +48
============================================
+ Hits 63926 64499 +573
- Misses 65702 65809 +107
- Partials 1913 1923 +10 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This PR generated automatically to merge rel-10.7 with rel-10.6. Please review the changed files before merging to prevent any errors that may occur.