This repository has been archived on 2023-02-02. You can view files and clone it, but cannot push or open issues or pull requests.
mfgames-nitride-cil/src/MfGames.Nitride.Handlebars/IdentifyHandlebarsFromContent.cs

37 lines
880 B
C#
Raw Permalink Normal View History

using System.Collections.Generic;
using System.Threading;
2022-09-06 05:53:22 +00:00
using MfGames.Gallium;
using MfGames.Nitride.Contents;
2022-09-06 05:53:22 +00:00
namespace MfGames.Nitride.Handlebars;
/// <summary>
/// An operation that discovers which text files have a Handlebars template
/// inside them.
/// </summary>
public class IdentifyHandlebarsFromContent : IOperation
{
/// <inheritdoc />
public IEnumerable<Entity> Run(
IEnumerable<Entity> input,
CancellationToken cancellationToken = default)
{
2022-07-09 04:52:10 +00:00
return input.SelectEntity<ITextContent>(this.ScanContent);
}
2022-07-09 04:52:10 +00:00
private Entity ScanContent(
Entity entity,
ITextContent content)
{
string text = content.GetTextContentString();
if (text.Contains("{{") && text.Contains("}}"))
{
return entity.Set(HasHandlebarsTemplate.Instance);
}
return entity;
}
}