Class RazorTemplateService
Provides methods for rendering Razor templates.
Implements
Inherited Members
Namespace: DataWeb.Templating
Assembly: DataWeb.Core.dll
Syntax
public class RazorTemplateService : IRazorTemplateService
Remarks
Initializes a new instance of the RazorTemplateService class.
Constructors
RazorTemplateService(IRazorViewEngine, ITempDataProvider, IServiceProvider)
Provides methods for rendering Razor templates.
Declaration
public RazorTemplateService(IRazorViewEngine viewEngine, ITempDataProvider tempDataProvider, IServiceProvider serviceProvider)
Parameters
Type | Name | Description |
---|---|---|
IRazorViewEngine | viewEngine | The Razor view engine. |
ITempDataProvider | tempDataProvider | The temporary data provider. |
IServiceProvider | serviceProvider | The service provider. |
Remarks
Initializes a new instance of the RazorTemplateService class.
Methods
RenderAsync(string, object, CancellationToken)
Renders the specified Razor template with the given model.
Declaration
public Task<string> RenderAsync(string name, object model, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | name | The name of the template to render. |
object | model | The model to pass to the template. |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task<string> | A string representing the rendered template. |
RenderAsync(string, CancellationToken)
Renders the specified Razor template.
Declaration
public Task<string> RenderAsync(string name, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | name | The name of the template to render. |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task<string> | A string representing the rendered template. |