Razor.Templating.Core 1.2.1

Render your .cshtml files to string. Works out of the box for Web, Console, Worker Service, Desktop Apps in .NET Core.

Install-Package Razor.Templating.Core -Version 1.2.1
dotnet add package Razor.Templating.Core --version 1.2.1
<PackageReference Include="Razor.Templating.Core" Version="1.2.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Razor.Templating.Core --version 1.2.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Razor.Templating.Core

Build+Test Nuget

Using Razor for HTML templating was never been so easy like this.

  • Works for .NET Core 3.0, 3.1
  • Works in Console, Worker Service, ASP.NET Core, Desktop(WPF, WinForms in .NET Core) Applications Independently

This project makes use of Razor SDK for precompiling the views.

Applications

  • Email Templating
  • Report Generation & so on

Installing Nuget Package

This library is available as Nuget package

Using .NET CLI
dotnet add package Razor.Templating.Core
Using Package Reference .csproj
<PackageReference Include="Razor.Templating.Core" Version="1.2.1" />

Simple Usage:

using Razor.Templating.Core;

var model = new ExampleModel()
{
    PlainText = "This text is rendered from Razor Views using Razor.Templating.Core",
    HtmlContent = "<em>You can use it to generate email content, report generation and so on</em>"
};

var viewData = new Dictionary<string, object>();
viewData["Value1"] = "1";
viewData["Value2"] = "2";

var html = await RazorTemplateEngine.RenderAsync("/Views/ExampleView.cshtml", model, viewData);

Before applying this code, follow this article for working implementation: https://medium.com/@soundaranbu/render-razor-view-cshtml-to-string-in-net-core-7d125f32c79

Razor Views in Library

Razor view files(.cshtml) can be organized in a separate shared libary. Sample library can be found here

Sample Applications

Please find the sample applications here

Note:

  • Please ensure that the views path is always unique among all the shared template projects.
References:

Thanks to all the great articles and projects which helped to bring this library out!

  • https://github.com/Andy9FromSpace/razor-renderer-core
  • https://github.com/aspnet/Entropy/tree/master/samples/Mvc.RenderViewToString
  • https://www.frakkingsweet.com/razor-template-rendering/
  • https://github.com/veccsolutions/RenderRazorConsole
  • https://emilol.com/razor-mailer/
  • https://codeopinion.com/using-razor-in-a-console-application/

Razor.Templating.Core

Build+Test Nuget

Using Razor for HTML templating was never been so easy like this.

  • Works for .NET Core 3.0, 3.1
  • Works in Console, Worker Service, ASP.NET Core, Desktop(WPF, WinForms in .NET Core) Applications Independently

This project makes use of Razor SDK for precompiling the views.

Applications

  • Email Templating
  • Report Generation & so on

Installing Nuget Package

This library is available as Nuget package

Using .NET CLI
dotnet add package Razor.Templating.Core
Using Package Reference .csproj
<PackageReference Include="Razor.Templating.Core" Version="1.2.1" />

Simple Usage:

using Razor.Templating.Core;

var model = new ExampleModel()
{
    PlainText = "This text is rendered from Razor Views using Razor.Templating.Core",
    HtmlContent = "<em>You can use it to generate email content, report generation and so on</em>"
};

var viewData = new Dictionary<string, object>();
viewData["Value1"] = "1";
viewData["Value2"] = "2";

var html = await RazorTemplateEngine.RenderAsync("/Views/ExampleView.cshtml", model, viewData);

Before applying this code, follow this article for working implementation: https://medium.com/@soundaranbu/render-razor-view-cshtml-to-string-in-net-core-7d125f32c79

Razor Views in Library

Razor view files(.cshtml) can be organized in a separate shared libary. Sample library can be found here

Sample Applications

Please find the sample applications here

Note:

  • Please ensure that the views path is always unique among all the shared template projects.
References:

Thanks to all the great articles and projects which helped to bring this library out!

  • https://github.com/Andy9FromSpace/razor-renderer-core
  • https://github.com/aspnet/Entropy/tree/master/samples/Mvc.RenderViewToString
  • https://www.frakkingsweet.com/razor-template-rendering/
  • https://github.com/veccsolutions/RenderRazorConsole
  • https://emilol.com/razor-mailer/
  • https://codeopinion.com/using-razor-in-a-console-application/

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
1.2.1 1,440 9/21/2020
1.2.0 1,485 7/11/2020
1.1.2 492 4/13/2020
1.1.0 97 4/13/2020
1.0.1 116 4/3/2020
1.0.0 127 4/3/2020