| | | 1 | | using Elsa.Caching.Features; |
| | | 2 | | using Elsa.Common.Features; |
| | | 3 | | using Elsa.Expressions.Features; |
| | | 4 | | using Elsa.Extensions; |
| | | 5 | | using Elsa.Features.Abstractions; |
| | | 6 | | using Elsa.Features.Attributes; |
| | | 7 | | using Elsa.Features.Services; |
| | | 8 | | using Elsa.Expressions.Liquid.Contracts; |
| | | 9 | | using Elsa.Expressions.Liquid.Filters; |
| | | 10 | | using Elsa.Expressions.Liquid.Handlers; |
| | | 11 | | using Elsa.Expressions.Liquid.Options; |
| | | 12 | | using Elsa.Expressions.Liquid.Providers; |
| | | 13 | | using Elsa.Expressions.Liquid.Services; |
| | | 14 | | using Fluid.Filters; |
| | | 15 | | using Microsoft.Extensions.DependencyInjection; |
| | | 16 | | |
| | | 17 | | namespace Elsa.Expressions.Liquid.Features; |
| | | 18 | | |
| | | 19 | | /// <summary> |
| | | 20 | | /// Configures liquid functionality. |
| | | 21 | | /// </summary> |
| | | 22 | | [DependsOn(typeof(MemoryCacheFeature))] |
| | | 23 | | [DependsOn(typeof(MediatorFeature))] |
| | | 24 | | [DependsOn(typeof(ExpressionsFeature))] |
| | | 25 | | public class LiquidFeature : FeatureBase |
| | | 26 | | { |
| | | 27 | | /// <inheritdoc /> |
| | 1 | 28 | | public LiquidFeature(IModule serviceConfiguration) : base(serviceConfiguration) |
| | | 29 | | { |
| | 1 | 30 | | } |
| | | 31 | | |
| | | 32 | | /// <summary> |
| | | 33 | | /// Configures the Fluid options. |
| | | 34 | | /// </summary> |
| | 3 | 35 | | public Action<FluidOptions> FluidOptions { get; set; } = options => |
| | 1 | 36 | | { |
| | 0 | 37 | | options.ConfigureFilters = context => context.Options.Filters |
| | 0 | 38 | | .WithArrayFilters() |
| | 0 | 39 | | .WithStringFilters() |
| | 0 | 40 | | .WithNumberFilters() |
| | 0 | 41 | | .WithMiscFilters(); |
| | 1 | 42 | | }; |
| | | 43 | | |
| | | 44 | | /// <inheritdoc /> |
| | | 45 | | public override void Apply() |
| | | 46 | | { |
| | 1 | 47 | | Services.Configure(FluidOptions); |
| | | 48 | | |
| | 1 | 49 | | Services |
| | 1 | 50 | | .AddHandlersFrom<ConfigureLiquidEngine>() |
| | 1 | 51 | | .AddScoped<ILiquidTemplateManager, LiquidTemplateManager>() |
| | 1 | 52 | | .AddScoped<LiquidParser>() |
| | 1 | 53 | | .AddExpressionDescriptorProvider<LiquidExpressionDescriptorProvider>() |
| | 1 | 54 | | .AddLiquidFilter<Base64Filter>("base64") |
| | 1 | 55 | | .AddLiquidFilter<DictionaryKeysFilter>("keys") |
| | 1 | 56 | | ; |
| | 1 | 57 | | } |
| | | 58 | | } |