Files
2025-10-11 13:08:09 +02:00

35 lines
892 B
C#

using Core.Exceptions;
using Core.Templates;
using Mustache;
namespace Generator.Infrastructure.TemplateFiller;
public class MustacheFiller : AbstractFiller
{
public MustacheFiller(ITemplate template)
{
Template = template;
}
/// <inheritdoc/>
public override void Fill()
{
var compiler = new FormatCompiler
{
RemoveNewLines = false
};
var generator = compiler.Compile(Template?.GetText());
Render = generator.Render(Template?.GetData());
}
/// <inheritdoc/>
public override void Write(string outputPath)
{
if (Render == null) throw new FillerException(
"Filler Exception : No text can be written. Have you forgot to call the Fill method ?");
using StreamWriter file = new StreamWriter(outputPath);
file.Write(Render);
}
}