From 4fa761577e085b89004cd53530cdb2dc2149a180 Mon Sep 17 00:00:00 2001 From: Drew Brasher Date: Wed, 20 Nov 2024 08:19:34 -0600 Subject: [PATCH 1/2] Added using statement to the Razor Helper usage example --- src/docs/reference/core/Razor/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/docs/reference/core/Razor/README.md b/src/docs/reference/core/Razor/README.md index 24ad6e5bce9..caaac509314 100644 --- a/src/docs/reference/core/Razor/README.md +++ b/src/docs/reference/core/Razor/README.md @@ -44,6 +44,7 @@ Many extensions methods are available in Razor with `@Orchard`. If you want to use an extension method in a view, you can inject an `IOrchardHelper` named `Orchard` at the top of your file: ```csharp +@using OrchardCore @inject OrchardCore.IOrchardHelper Orchard ``` @@ -52,6 +53,7 @@ In `OrchardCore.DisplayManagement.Razor`, there is a RazorPage that already has If you want to use an Orchard helper in a controller, you can inject an instance in the constructor: ```csharp +using OrchardCore; private IOrchardHelper _orchard; public MyClass(IOrchardHelper orchard) From d20f365cddeac2346f24f39514a0085a8a703fc1 Mon Sep 17 00:00:00 2001 From: Drew Brasher Date: Wed, 20 Nov 2024 15:27:46 -0600 Subject: [PATCH 2/2] Updated the Razor Helper usage example --- src/docs/reference/core/Razor/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/docs/reference/core/Razor/README.md b/src/docs/reference/core/Razor/README.md index caaac509314..fe4c9f85319 100644 --- a/src/docs/reference/core/Razor/README.md +++ b/src/docs/reference/core/Razor/README.md @@ -44,8 +44,9 @@ Many extensions methods are available in Razor with `@Orchard`. If you want to use an extension method in a view, you can inject an `IOrchardHelper` named `Orchard` at the top of your file: ```csharp +// You can also put this into a _ViewImports.cshtml file so it's applied to all templates. @using OrchardCore -@inject OrchardCore.IOrchardHelper Orchard +@inject IOrchardHelper Orchard ``` In `OrchardCore.DisplayManagement.Razor`, there is a RazorPage that already has a public property `Orchard` that you can use to call an extension method or the current `HttpContext`.