Composer.StringTemplate 1.0.0

dotnet add package Composer.StringTemplate --version 1.0.0                
NuGet\Install-Package Composer.StringTemplate -Version 1.0.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Composer.StringTemplate" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Composer.StringTemplate --version 1.0.0                
#r "nuget: Composer.StringTemplate, 1.0.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Composer.StringTemplate as a Cake Addin
#addin nuget:?package=Composer.StringTemplate&version=1.0.0

// Install Composer.StringTemplate as a Cake Tool
#tool nuget:?package=Composer.StringTemplate&version=1.0.0                

Template provider for Composer using StringTemplate 4

This is a template provider for Composer using StringTemplate 4.

Usage

services
    .AddComposer()
    .AddSender<SenderImplementation>()
    .AddStringTemplate()
    .AddTemplateRepository<RepositoryImplementation>();

RepositoryImplementation is an implementation of ITemplateRepository.

Template syntax

We use formal syntax (AKA. group syntax) with $ as delimiter. You need to define the following templates for each email:

  • subject(recipients, data): Subject template.
  • plain(recipients, data): Plain text body message.

Example:

subject(recipients, data) ::= "Welcome to our awesome website!"
plain(recipients, data) ::= <<
Hello $data.username$!,

Thank you for sign up with us. You email address is $first(recipients); format="address"$.
>>
Template parameters
  • recipients: A collection of recipients. Each items is is either MimeKit.MailboxAddress or MimeKit.GroupAddress.
  • data: Data provided from class definition of the email.

Property renderer

You can alter how data is rendered by create an implementation of IPropertyRenderer. See here for a guide. The default behavior is using output from ToString. Once finished you need to register your renderer by invoke AddPropertyRenderer:

services
    .AddComposer()
    .AddSender<SenderImplementation>()
    .AddStringTemplate()
    .AddTemplateRepository<RepositoryImplementation>()
    .AddPropertyRenderer<YourRenderer>();

Built-in property renderers

MimeKit.MailboxAddress

Available formats:

  • name: Output only display name of the address (e.g. John Doe). Be aware that this may produce empty string in most cases due to usually email address does not contain display name.
  • address: Output only address (e.g. john@example.com).
  • full: Output both (e.g. John Doe john@example.com).

License

MIT

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.0 297 3/5/2022