Razor Templating Engine to render Razor Views(.cshtml files) to String in Console, Web, Service, Desktop workloads in .NET Core 3+
Full Changelog: https://github.com/soundaranbu/Razor.Templating.Core/compare/v1.9.0...v2.0.0
+ Task<(bool ViewExists, string? RenderedView)> TryRenderAsync(string viewName, object? viewModel = null, Dictionary<string, object>? viewBagOrViewData = null);
+ Task<(bool ViewExists, string? RenderedView)> TryRenderPartialAsync(string viewName, object? viewModel = null, Dictionary<string, object>? viewBagOrViewData = null);
// This method can be safely removed and it has no effect
- Initialize()
// Use the non-generic variant instead
- Task<string> RenderAsync<TModel>(string viewName, object viewModel, Dictionary<string, object> viewBagOrViewData)
Full Changelog: https://github.com/soundaranbu/Razor.Templating.Core/compare/v1.9.0...v2.0.0-rc.1
Full Changelog: https://github.com/soundaranbu/Razor.Templating.Core/compare/v1.8.0...v1.9.0
IWebHostEnvironment
when it's already presentRenderPartialAsync
when you don't need a layout page … by @mobiletonster in https://github.com/soundaranbu/Razor.Templating.Core/pull/52
Full Changelog: https://github.com/soundaranbu/Razor.Templating.Core/compare/v1.8.0...v1.9.0-rc.1
Full Changelog: https://github.com/soundaranbu/Razor.Templating.Core/compare/v1.7.1...v1.8.0
IRazorTemplateEngine
interface & allow dependency injection through constructor by @pbolduc in #48public interface IRazorTemplateEngine
{
/// <summary>
/// Renders View(.cshtml) To String
/// </summary>
/// <param name="viewName">Relative path of the .cshtml view. Eg: /Views/YourView.cshtml or ~/Views/YourView.cshtml</param>
/// <param name="viewModel">Optional model data</param>
/// <param name="viewBagOrViewData">Optional view bag or view data</param>
/// <returns></returns>
Task<string> RenderAsync(string viewName, object? viewModel = null, Dictionary<string, object>? viewBagOrViewData = null);
}
Task<string> RenderAsync(string viewName, object? viewModel = null, Dictionary<string, object>? viewBagOrViewData = null);
RazorTemplateEngine.Initialize()
is not used anymore and hence is marked as obsolete. Users can safely remove it. This method will be removed in v2.0.0RenderAsync
method with generic type is not used anymore. Users will need to use the alternate RenderAsync
method without a generic type param. This API with generic type param will be removed in v2.0.0//before
var html = await RazorTemplateEngine.RenderAsync<object>("~/Index.cshtml", null, viewData);
//after
var html = await RazorTemplateEngine.RenderAsync("~/Index.cshtml", null, viewData);
Full Changelog: https://github.com/soundaranbu/Razor.Templating.Core/compare/v1.7.1...v1.8.0-rc.1
v1.6.x
Full Changelog: https://github.com/soundaranbu/RazorTemplating/compare/v1.7.0...v1.7.1
Full Changelog: https://github.com/soundaranbu/RazorTemplating/compare/v1.7.0...v1.7.1-rc.1
Changes:
Note:
Full Changelog: https://github.com/soundaranbu/RazorTemplating/compare/v1.6.0...v1.6.1-rc.1