Sparkdo.TextTemplating.Abstractions 1.0.1

There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package Sparkdo.TextTemplating.Abstractions --version 1.0.1
                    
NuGet\Install-Package Sparkdo.TextTemplating.Abstractions -Version 1.0.1
                    
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="Sparkdo.TextTemplating.Abstractions" Version="1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Sparkdo.TextTemplating.Abstractions" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="Sparkdo.TextTemplating.Abstractions" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Sparkdo.TextTemplating.Abstractions --version 1.0.1
                    
#r "nuget: Sparkdo.TextTemplating.Abstractions, 1.0.1"
                    
#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.
#:package Sparkdo.TextTemplating.Abstractions@1.0.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Sparkdo.TextTemplating.Abstractions&version=1.0.1
                    
Install as a Cake Addin
#tool nuget:?package=Sparkdo.TextTemplating.Abstractions&version=1.0.1
                    
Install as a Cake Tool

Sparkdo.TextTemplating.Abstractions

Sparkdo 文本模板抽象库,提供文本模板功能的核心接口和基础类实现。

功能特性

  • 文本模板核心接口定义
  • 模板定义管理
  • 模板渲染引擎抽象
  • 模板内容提供者抽象
  • 与 Sparkdo 框架无缝集成

安装

<PackageReference Include="Sparkdo.TextTemplating.Abstractions" Version="x.x.x" />

核心组件

模板定义

  • TemplateDefinition: 模板定义类,用于定义模板的基本信息
  • ITemplateDefinitionManager: 模板定义管理器接口
  • ITemplateDefinitionProvider: 模板定义提供程序接口
  • TemplateDefinitionProvider: 模板定义提供程序抽象基类

模板渲染

  • ITemplateRenderer: 模板渲染器接口
  • ITemplateRenderingEngine: 模板渲染引擎接口
  • TemplateRenderingEngineBase: 模板渲染引擎基类

模板内容

  • ITemplateContentProvider: 模板内容提供者接口
  • ITemplateContentContributor: 模板内容贡献者接口

配置

  • SparkdoTextTemplatingOptions: 文本模板选项类
  • SparkdoTextTemplatingAbstractionsModule: 文本模板抽象模块配置

使用示例

通过 TemplateDefinitionProvider 注册模板定义

public class MyTemplateDefinitionProvider : TemplateDefinitionProvider
{
    public override void Define(ITemplateDefinitionContext context)
    {
        context.Add(new TemplateDefinition("MyTemplate")
            .WithContent("Hello {{ model.name }}!")
        );
    }
}

实现自定义模板渲染引擎

public class MyTemplateRenderingEngine : TemplateRenderingEngineBase
{
    public const string EngineName = "MyEngine";
    
    public override string Name => EngineName;

    public override async Task<string> RenderAsync(
        string templateName,
        object? model = null,
        string? cultureName = null,
        Dictionary<string, object>? globalContext = null)
    {
        // 实现渲染逻辑
        return "Rendered content";
    }
}

扩展性

该库提供了完整的文本模板抽象实现,可以通过以下方式扩展:

  1. 实现具体的模板渲染引擎
  2. 实现自定义的模板内容提供者
  3. 通过 TemplateDefinitionProvider 注册模板定义
  4. 实现自定义的模板内容贡献者

代码结构说明

本项目包含以下主要组件:

核心接口

  • ITemplateDefinitionManager: 模板定义管理器接口
  • ITemplateDefinitionProvider: 模板定义提供程序接口
  • ITemplateRenderer: 模板渲染器接口
  • ITemplateRenderingEngine: 模板渲染引擎接口
  • ITemplateContentProvider: 模板内容提供者接口
  • ITemplateContentContributor: 模板内容贡献者接口

核心实现

  • TemplateDefinition: 模板定义类
  • TemplateDefinitionProvider: 模板定义提供程序抽象基类
  • TemplateRenderingEngineBase: 模板渲染引擎基类
  • DefaultTemplateRenderer: 默认模板渲染器实现
  • DefaultTemplateDefinitionManager: 默认模板定义管理器实现

配置

  • SparkdoTextTemplatingOptions: 文本模板选项类
  • SparkdoTextTemplatingAbstractionsModule: 文本模板抽象模块配置

所有公共接口和类都添加了详细的 XML 文档注释,便于开发者理解和使用。

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (3)

Showing the top 3 NuGet packages that depend on Sparkdo.TextTemplating.Abstractions:

Package Downloads
Sparkdo.Emailing

Sparkdo 邮件发送库,提供基于 SMTP 的邮件发送功能,支持同步/异步发送、后台队列发送和模板邮件

Sparkdo.TextTemplating.Scriban

Sparkdo 框架的文本模板 Scriban 引擎实现。基于 Scriban 库提供强大的模板渲染功能,支持本地化、模型绑定和复杂模板逻辑。

Sparkdo.TextTemplating.Razor

Sparkdo 框架的文本模板 Razor 引擎实现。提供基于 Razor 语法的文本模板渲染功能。

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.2-preview.1 142 12/4/2025
1.0.1 325 11/27/2025
1.0.0 334 11/25/2025
1.0.0-preview.5 93 10/24/2025