123456789101112131415161718192021222324 |
- using System.Diagnostics;
- using System.IO;
- using System.Threading.Tasks;
- using AspNetCoreSsrTemplateEngine.DataBoundContext;
- namespace AspNetCoreSsrTemplateEngine.Renders
- {
- [DebuggerDisplay("TEMPLATE: {" + nameof(Key) + ",nq}")]
- internal class TemplateRender : IRender
- {
- public string Key { get; }
- public TemplateRender(string key)
- {
- Key = key;
- }
- public async Task RenderAsync(IReadonlyDataBindContext dataBindContext, Stream stream)
- {
- if (false == dataBindContext.TryGetTemplate(Key, out var template)) throw new SteException($"Template `{Key}' not found in context ");
- await template.RenderAsync(dataBindContext, stream);
- }
- }
- }
|