Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Template Engine #120

Closed
Tracked by #82
WeihanLi opened this issue Jul 28, 2021 · 3 comments
Closed
Tracked by #82

Template Engine #120

WeihanLi opened this issue Jul 28, 2021 · 3 comments
Labels

Comments

@WeihanLi
Copy link
Owner

No description provided.

@WeihanLi WeihanLi mentioned this issue Jul 28, 2021
12 tasks
@stale
Copy link

stale bot commented Mar 13, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the inactive label Mar 13, 2022
@WeihanLi
Copy link
Owner Author

Please keep it open

@stale stale bot removed the inactive label Mar 14, 2022
@WeihanLi
Copy link
Owner Author

WeihanLi commented Jul 1, 2022

API proposal:

public interface ITextTemplate
{
    string Text { get; }
    HashSet<string> Variables { get; }
}

public interface ITemplateParser
{
    Task<ITextTemplate> ParseAsync(string text);
}

public interface ITemplateRenderer
{
   Task<string> RenderAsync(ITextTemplate template, object globals);
}

public class TextTemplateContext: ITextTemplate,IProperties
{
  public TextTemplateContext(string text, HashSet<string> variables)
  {
    Text = text;
    Variables = variables;
  } 

  public string Text { get; }
  public HashSet<string> Variables { get; }
  public IDictionary<string, object?> Properties { get; } = new Dictionary<string, object?>();
}

public interface ITemplateRendererBuilder
{
   ITemplateRendererBuilder UseMiddleware(Func<TextTemplateContext, Task> middleware);
   ITemplateRender Build();
}

@WeihanLi WeihanLi mentioned this issue Oct 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant