ubeac / ubeac-api

Source of uBeac .NET Core packages
3 stars 2 forks source link

Implement Template Engine #158

Open ilhesam opened 1 year ago

ilhesam commented 1 year ago

We should implement CRUD and Rendering in this phase.

uBeac.Core.TemplateRendering.Abstractions

We will have an entity:

public class ContentTemplate // inherits from base entity
{
    public string UniqueKey { get; set; } // "sign-up-email"
    public string? Subject { get; set; } // It's optional, "Welcome to {{SiteName}}"
    public string Body { get; set; } // "Hello {{Name}}, Your account has been created successfully!"
}

And a model:

public class RenderedContent
{
    public string? Subject { get; set; }
    public string Body { get; set; }
}

Also, we should create a repository, service and renderer with the CRUD + rendering methods:

public interface IContentTemplateRepository // inherits from base repository
{
    // CRUD methods
}

public interface IContentTemplateService // inherits from base repository
{
    // CRUD methods

    RenderedContent Render(ContentTemplate template, object model);
}

public interface ITemplateRenderer
{
    string Render(string template, object model);
}

And, we should implement these interfaces in the another packages:

ilhesam commented 1 year ago

It's good to take a look at it. https://github.com/Handlebars-Net Handlebars have a good community and support in .NET. and we can have it next to the Mustache. @pournasserian