public static void ConfigureLiquid(this IServiceCollection services, Action <LiquidOptions> setupAction = null) { LiquidOptions options; if (services.Any(x => x.ServiceType == typeof(LiquidOptions))) { var sp = services.BuildServiceProvider(); options = sp.GetService <LiquidOptions>(); setupAction?.Invoke(options); } else { services.AddMemoryCache(); options = new LiquidOptions(services); setupAction?.Invoke(options); options.AddCommonLiquidFilters(); services.AddSingleton(options); services.AddTransient <ISlugService, SlugService>(); services.AddTransient <ILiquidTemplateManager, LiquidTemplateManager>(); ConfigureFluid(); } }
public static LiquidOptions AddFilter <T>(this LiquidOptions options) where T : class, ILiquidFilter { options.Services.AddTransient <T>(); var filterName = LiquidFilterNameAttribute.GetName(typeof(T)); options.FilterRegistrations.Add(filterName, typeof(T)); return(options); }
public LiquidTemplateManager( IMemoryCache memoryCache, LiquidOptions options, IServiceProvider serviceProvider) { _memoryCache = memoryCache; _liquidOptions = options; _serviceProvider = serviceProvider; }
private static void AddCommonLiquidFilters(this LiquidOptions options) { options.AddFilter <SlugifyFilter>() .AddFilter <JsonFilter>() .AddFilter <LiquidFilter>(); }