Sparkdo.TextTemplating.Abstractions 1.0.3

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.3
                    
NuGet\Install-Package Sparkdo.TextTemplating.Abstractions -Version 1.0.3
                    
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.3" />
                    
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.3" />
                    
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.3
                    
#r "nuget: Sparkdo.TextTemplating.Abstractions, 1.0.3"
                    
#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.3
                    
#: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.3
                    
Install as a Cake Addin
#tool nuget:?package=Sparkdo.TextTemplating.Abstractions&version=1.0.3
                    
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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (4)

Showing the top 4 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 语法的文本模板渲染功能。

Sparkdo.TextTemplating

Sparkdo 文本模板默认运行时:冻结字典模板目录、内容贡献者责任链、区域性回退、带布局支持的纯文本引擎与 AddSparkdoTextTemplating 一行接线。

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
3.0.0-preview.1 72 10/30/2026
2.0.0-preview.2 110 7/20/2026
1.0.4-preview.3 121 6/8/2026
1.0.4-preview.2 104 6/7/2026
1.0.4-preview.1 121 6/7/2026
1.0.3 240 6/6/2026
1.0.3-preview.1 109 5/17/2026
1.0.2 196 4/27/2026
1.0.2-preview.5 102 4/15/2026
1.0.2-preview.4 120 2/8/2026
1.0.2-preview.3 120 2/1/2026
1.0.2-preview.2 109 1/31/2026
1.0.2-preview.1 222 12/4/2025
1.0.1 416 11/27/2025
1.0.0 427 11/25/2025
1.0.0-preview.5 176 10/24/2025