<commit_before>using System;
using System.Linq;
using System.Threading.Tasks;
using Fluid;
using Fluid.Values;
using Microsoft.Extensions.DependencyInjection;
using OrchardCore.ContentManagement;
using OrchardCore.Liquid;

namespace OrchardCore.Contents.Liquid
{
    public class ContentItemFilter : ILiquidFilter
    {
        public async ValueTask<FluidValue> ProcessAsync(FluidValue input, FilterArguments arguments, TemplateContext ctx)
        {
            if (!ctx.AmbientValues.TryGetValue("Services", out var services))
            {
                throw new ArgumentException("Services missing while invoking 'content_item_id'");
            }

            var contentManager = ((IServiceProvider)services).GetRequiredService<IContentManager>();

            if (input.Type == FluidValues.Array)
            {
                // List of content item ids

                var contentItemIds = input.Enumerate().Select(x => x.ToStringValue()).ToArray();

                return FluidValue.Create(await contentManager.GetAsync(contentItemIds));
            }
            else
            {
                var contentItemId = input.ToString();

                return FluidValue.Create(await contentManager.GetAsync(contentItemId));
            }
        }
    }
}<commit_msg>Fixes content_item_id filter for the single ID (#3696)<commit_after>using System;
using System.Linq;
using System.Threading.Tasks;
using Fluid;
using Fluid.Values;
using Microsoft.Extensions.DependencyInjection;
using OrchardCore.ContentManagement;
using OrchardCore.Liquid;

namespace OrchardCore.Contents.Liquid
{
    public class ContentItemFilter : ILiquidFilter
    {
        public async ValueTask<FluidValue> ProcessAsync(FluidValue input, FilterArguments arguments, TemplateContext ctx)
        {
            if (!ctx.AmbientValues.TryGetValue("Services", out var services))
            {
                throw new ArgumentException("Services missing while invoking 'content_item_id'");
            }

            var contentManager = ((IServiceProvider)services).GetRequiredService<IContentManager>();

            if (input.Type == FluidValues.Array)
            {
                // List of content item ids

                var contentItemIds = input.Enumerate().Select(x => x.ToStringValue()).ToArray();

                return FluidValue.Create(await contentManager.GetAsync(contentItemIds));
            }
            else
            {
                var contentItemId = input.ToStringValue();

                return FluidValue.Create(await contentManager.GetAsync(contentItemId));
            }
        }
    }
}
{'fraction_non_alphanumeric': 0.0860091743119266, 'fraction_numerical': 0.0015290519877675841, 'mean_word_length': 2.498663101604278, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1920277', 'n_tokens_mistral': 674, 'n_tokens_neox': 646, 'n_words': 143}