< Summary

Information
Class: Elsa.Expressions.Liquid.Expressions.LiquidExpressionHandler
Assembly: Elsa.Expressions.Liquid
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Expressions.Liquid/Expressions/LiquidExpressionHandler.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 7
Coverable lines: 7
Total lines: 30
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 2
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%210%
EvaluateAsync()0%620%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Expressions.Liquid/Expressions/LiquidExpressionHandler.cs

#LineLine coverage
 1using Elsa.Expressions.Contracts;
 2using Elsa.Expressions.Helpers;
 3using Elsa.Expressions.Models;
 4using Elsa.Expressions.Liquid.Contracts;
 5
 6namespace Elsa.Expressions.Liquid.Expressions;
 7
 8/// <summary>
 9/// Evaluates a Liquid expression.
 10/// </summary>
 11public class LiquidExpressionHandler : IExpressionHandler
 12{
 13    private readonly ILiquidTemplateManager _liquidTemplateManager;
 14
 15    /// <summary>
 16    /// Initializes a new instance of the <see cref="LiquidExpressionHandler"/> class.
 17    /// </summary>
 018    public LiquidExpressionHandler(ILiquidTemplateManager liquidTemplateManager)
 19    {
 020        _liquidTemplateManager = liquidTemplateManager;
 021    }
 22
 23    /// <inheritdoc />
 24    public async ValueTask<object?> EvaluateAsync(Expression expression, Type returnType, ExpressionExecutionContext con
 25    {
 026        var liquidExpression = expression.Value.ConvertTo<string>() ?? "";
 027        var renderedString = await _liquidTemplateManager.RenderAsync(liquidExpression, context);
 028        return renderedString.ConvertTo(returnType);
 029    }
 30}