First commit
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
using Tesses.WebServer;
|
||||
using Scriban;
|
||||
namespace Tesses.YouTubeDownloader2025Companion
|
||||
{
|
||||
public class ReloadingScript(string path)
|
||||
{
|
||||
DateTime created=new DateTime(1970,1,1);
|
||||
Template? template;
|
||||
private string path = path;
|
||||
|
||||
public string Render(object val)
|
||||
{
|
||||
Template? template;
|
||||
lock(this)
|
||||
{
|
||||
template = this.template;
|
||||
var cd = File.GetLastWriteTime(path);
|
||||
if(cd > created || this.template is null)
|
||||
{
|
||||
|
||||
template = Template.Parse(File.ReadAllText(path));
|
||||
this.template = template;
|
||||
created = cd;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if(template is not null)
|
||||
{
|
||||
return template.Render(val);
|
||||
}
|
||||
throw new FileNotFoundException("Not found");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user