37 lines
880 B
C#
37 lines
880 B
C#
using System.Collections.Generic;
|
|
using System.Threading;
|
|
|
|
using MfGames.Gallium;
|
|
using MfGames.Nitride.Contents;
|
|
|
|
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)
|
|
{
|
|
return input.SelectEntity<ITextContent>(this.ScanContent);
|
|
}
|
|
|
|
private Entity ScanContent(
|
|
Entity entity,
|
|
ITextContent content)
|
|
{
|
|
string text = content.GetTextContentString();
|
|
|
|
if (text.Contains("{{") && text.Contains("}}"))
|
|
{
|
|
return entity.Set(HasHandlebarsTemplate.Instance);
|
|
}
|
|
|
|
return entity;
|
|
}
|
|
}
|