-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
38 lines (31 loc) · 1.25 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
using System;
using System.IO;
using Scriban;
class Program
{
static void Main()
{
string templateDirectory = "./templates"; // Directory containing your Scriban templates
string outputDirectory = "output";
// Get all Scriban template files in the template directory
string[] templatePaths = Directory.GetFiles(templateDirectory, "*.sb");
foreach (string templatePath in templatePaths)
{
// Read Scriban template from file
string templateContent = File.ReadAllText(templatePath);
// Process the template
var template = Template.Parse(templateContent);
var result = template.Render();
// Create the output directory if it doesn't exist
if (!Directory.Exists(outputDirectory))
{
Directory.CreateDirectory(outputDirectory);
}
// Write the result to an HTML file
string outputFileName = Path.GetFileNameWithoutExtension(templatePath) + ".html";
string outputPath = Path.Combine(outputDirectory, outputFileName);
File.WriteAllText(outputPath, result);
Console.WriteLine($"Static page generated at: {outputPath}");
}
}
}