This repository has been archived on 2023-02-02. You can view files and clone it, but cannot push or open issues or pull requests.
mfgames-nitride-cil/src/MfGames.Nitride.Handlebars/NitrideHandlebarsModule.cs

40 lines
1 KiB
C#
Raw Normal View History

using System.Collections.Generic;
2021-09-07 05:15:45 +00:00
using Autofac;
using HandlebarsDotNet;
2022-09-06 05:53:22 +00:00
using MfGames.Nitride.Handlebars.Configuration;
2022-09-06 05:53:22 +00:00
namespace MfGames.Nitride.Handlebars;
public class NitrideHandlebarsModule : Module
2021-09-07 05:15:45 +00:00
{
/// <inheritdoc />
protected override void Load(ContainerBuilder builder)
2021-09-07 05:15:45 +00:00
{
builder.RegisterOperators(this);
builder.RegisterValidators(this);
2022-07-09 04:52:10 +00:00
builder.RegisterType<HandlebarsTemplateCache>()
.AsSelf()
.SingleInstance();
builder.Register(
(context) =>
{
IHandlebars handlebars = HandlebarsDotNet.Handlebars.Create();
IEnumerable<IHandlebarsLoader> helpers = context.Resolve<IEnumerable<IHandlebarsLoader>>();
2022-07-09 04:52:10 +00:00
foreach (IHandlebarsLoader helper in helpers)
{
helper.Register(handlebars);
}
return handlebars;
})
.As<IHandlebars>()
.SingleInstance();
2021-09-07 05:15:45 +00:00
}
}