Esempio n. 1
0
        public static FluidValue DividedBy(FluidValue input, FilterArguments arguments, TemplateContext context)
        {
            var     first   = arguments.At(0);
            decimal divisor = first.ToNumberValue();

            // The result is rounded down to the nearest integer(that is, the floor) if the divisor is an integer.
            // https://shopify.github.io/liquid/filters/divided_by/

            var result = input.ToNumberValue() / divisor;

            if (NumberValue.GetScale(divisor) == 0)
            {
                return(NumberValue.Create(decimal.Floor(result)));
            }

            return(NumberValue.Create(result));
        }