コード例 #1
0
 public ConfigureLiquidEngine(IConfiguration configuration, IWorkflowStorageService workflowStorageService, IOptions <LiquidOptions> liquidOptions, IActivityTypeService activityTypeService)
 {
     _configuration          = configuration;
     _workflowStorageService = workflowStorageService;
     _liquidOptions          = liquidOptions.Value;
     _activityTypeService    = activityTypeService;
 }
コード例 #2
0
 public LiquidTemplateManager(LiquidParser parser, IMemoryCache memoryCache, IOptions <LiquidOptions> options, IServiceProvider serviceProvider)
 {
     _parser          = parser;
     _memoryCache     = memoryCache;
     _serviceProvider = serviceProvider;
     _options         = options.Value;
 }
コード例 #3
0
 public LiquidTemplateManager(
     IMemoryCache memoryCache,
     IOptions <LiquidOptions> options,
     IServiceProvider serviceProvider)
 {
     _memoryCache     = memoryCache;
     _liquidOptions   = options.Value;
     _serviceProvider = serviceProvider;
 }
コード例 #4
0
 internal static void AddAsyncFilters(this TemplateContext templateContext, LiquidOptions options, IServiceProvider services)
 {
     foreach (var registration in options.FilterRegistrations)
     {
         templateContext.Filters.AddAsyncFilter(registration.Key, (input, arguments, ctx) =>
         {
             var filter = (ILiquidFilter)services.GetRequiredService(registration.Value);
             return(filter.ProcessAsync(input, arguments, ctx));
         });
     }
 }
コード例 #5
0
        internal static void AddAsyncFilters(this LiquidTemplateContext context, LiquidOptions options)
        {
            context.Filters.EnsureCapacity(options.FilterRegistrations.Count);

            foreach (var registration in options.FilterRegistrations)
            {
                context.Filters.AddAsyncFilter(registration.Key, (input, arguments, ctx) =>
                {
                    var filter = (ILiquidFilter)context.Services.GetRequiredService(registration.Value);
                    return(filter.ProcessAsync(input, arguments, ctx));
                });
            }
        }
コード例 #6
0
        public async Task Render()
        {
            var options = new LiquidOptions();

            var parser   = new LiquidParser(new OptionsWrapper <LiquidOptions>(options));
            var template = parser.Parse("{% render 'header' %}");

            var root = Path.Combine(Path.GetDirectoryName(GetType().Assembly.Location), "Scripting\\Liquid");

            var context = new TemplateContext(options)
            {
                Options =
                {
                    FileProvider = new PhysicalFileProvider(root)
                }
            };
            var rendered = await template.RenderAsync(context);

            Assert.Equal("<h2>YES</h2>", rendered);
        }
コード例 #7
0
 public LiquidTemplateManager(IMemoryCache memoryCache, IOptions <LiquidOptions> options, IServiceProvider serviceProvider)
 {
     this.memoryCache     = memoryCache;
     this.serviceProvider = serviceProvider;
     this.options         = options.Value;
 }