Razor Templates
This commit is contained in:
@ -9,6 +9,7 @@ using System.Threading.Tasks;
|
||||
using PdfSharp.Pdf.IO;
|
||||
using PuppeteerSharp;
|
||||
using PuppeteerSharp.Media;
|
||||
using RazorLight;
|
||||
using WGneu.Windows;
|
||||
|
||||
namespace WGneu.Documents {
|
||||
@ -16,9 +17,11 @@ namespace WGneu.Documents {
|
||||
|
||||
private static readonly string CHROMIUM = @"C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe";
|
||||
private static IBrowser? _Browser = null;
|
||||
private static RazorLightEngine? _Engine = null;
|
||||
|
||||
public static void Init() {
|
||||
var b = Browser;
|
||||
var e = Engine;
|
||||
}
|
||||
|
||||
private static IBrowser Browser {
|
||||
@ -31,6 +34,16 @@ namespace WGneu.Documents {
|
||||
}
|
||||
}
|
||||
|
||||
private static RazorLightEngine Engine {
|
||||
get {
|
||||
_Engine ??= new RazorLightEngineBuilder()
|
||||
.UseFileSystemProject(@"C:\Users\Lorenz\source\repos\WGneu\WGneu\Documents")
|
||||
.UseMemoryCachingProvider()
|
||||
.Build();
|
||||
return _Engine;
|
||||
}
|
||||
}
|
||||
|
||||
public static async Task Convert(string path_html, string path_pdf) {
|
||||
using var page = await Browser.NewPageAsync();
|
||||
await page.GoToAsync("file://" + path_html);
|
||||
@ -59,5 +72,9 @@ namespace WGneu.Documents {
|
||||
var w = new DocumentViewerWindow(title, path);
|
||||
w.Show();
|
||||
}
|
||||
|
||||
public static async Task<string> CompileRenderAsync(string key, object model) {
|
||||
return await Engine.CompileRenderAsync(key, model);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user