18 changed files with 1408 additions and 0 deletions
@ -0,0 +1,81 @@ |
|||
# LINGYUN.Abp.TextTemplating.Application.Contracts |
|||
|
|||
## Module Description |
|||
|
|||
Text templating application service contracts module, providing interface definitions and DTOs for text template management. |
|||
|
|||
### Base Modules |
|||
|
|||
* Volo.Abp.TextTemplating |
|||
* Volo.Abp.Ddd.Application.Contracts |
|||
|
|||
### Features |
|||
|
|||
* Provides application service interfaces for text template management |
|||
* ITextTemplateDefinitionAppService - Template definition management service interface |
|||
* ITextTemplateContentAppService - Template content management service interface |
|||
* Provides DTO definitions for text templates |
|||
* TextTemplateDefinitionDto - Template definition DTO |
|||
* TextTemplateContentDto - Template content DTO |
|||
* TextTemplateDefinitionCreateDto - Create template definition DTO |
|||
* TextTemplateDefinitionUpdateDto - Update template definition DTO |
|||
* TextTemplateContentUpdateDto - Update template content DTO |
|||
* Provides permission definitions for text template management |
|||
|
|||
### Permission Definitions |
|||
|
|||
* AbpTextTemplating.TextTemplateDefinitions |
|||
* Create - Create template definition |
|||
* Update - Update template definition |
|||
* Delete - Delete template definition |
|||
* AbpTextTemplating.TextTemplateContents |
|||
* Update - Update template content |
|||
* Delete - Delete template content |
|||
|
|||
### Application Service Interfaces |
|||
|
|||
* ITextTemplateDefinitionAppService |
|||
* GetAsync - Get template definition |
|||
* GetListAsync - Get template definition list |
|||
* CreateAsync - Create template definition |
|||
* UpdateAsync - Update template definition |
|||
* DeleteAsync - Delete template definition |
|||
* ITextTemplateContentAppService |
|||
* GetAsync - Get template content |
|||
* UpdateAsync - Update template content |
|||
* DeleteAsync - Delete template content |
|||
* RestoreAsync - Restore template content |
|||
|
|||
### How to Use |
|||
|
|||
1. Add `AbpTextTemplatingApplicationContractsModule` dependency |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpTextTemplatingApplicationContractsModule))] |
|||
public class YouProjectModule : AbpModule |
|||
{ |
|||
} |
|||
``` |
|||
|
|||
2. Inject and use template service interfaces |
|||
|
|||
```csharp |
|||
public class YourService |
|||
{ |
|||
private readonly ITextTemplateDefinitionAppService _templateDefinitionAppService; |
|||
|
|||
public YourService(ITextTemplateDefinitionAppService templateDefinitionAppService) |
|||
{ |
|||
_templateDefinitionAppService = templateDefinitionAppService; |
|||
} |
|||
|
|||
public async Task ManageTemplateAsync() |
|||
{ |
|||
// Get template definition list |
|||
var templates = await _templateDefinitionAppService.GetListAsync( |
|||
new TextTemplateDefinitionGetListInput()); |
|||
} |
|||
} |
|||
``` |
|||
|
|||
[查看中文](README.md) |
|||
@ -0,0 +1,81 @@ |
|||
# LINGYUN.Abp.TextTemplating.Application.Contracts |
|||
|
|||
## 模块说明 |
|||
|
|||
文本模板应用服务契约模块,提供文本模板管理相关的接口定义和DTO。 |
|||
|
|||
### 基础模块 |
|||
|
|||
* Volo.Abp.TextTemplating |
|||
* Volo.Abp.Ddd.Application.Contracts |
|||
|
|||
### 功能定义 |
|||
|
|||
* 提供文本模板管理的应用服务接口 |
|||
* ITextTemplateDefinitionAppService - 模板定义管理服务接口 |
|||
* ITextTemplateContentAppService - 模板内容管理服务接口 |
|||
* 提供文本模板相关的DTO定义 |
|||
* TextTemplateDefinitionDto - 模板定义DTO |
|||
* TextTemplateContentDto - 模板内容DTO |
|||
* TextTemplateDefinitionCreateDto - 创建模板定义DTO |
|||
* TextTemplateDefinitionUpdateDto - 更新模板定义DTO |
|||
* TextTemplateContentUpdateDto - 更新模板内容DTO |
|||
* 提供文本模板管理相关的权限定义 |
|||
|
|||
### 权限定义 |
|||
|
|||
* AbpTextTemplating.TextTemplateDefinitions |
|||
* Create - 创建模板定义 |
|||
* Update - 更新模板定义 |
|||
* Delete - 删除模板定义 |
|||
* AbpTextTemplating.TextTemplateContents |
|||
* Update - 更新模板内容 |
|||
* Delete - 删除模板内容 |
|||
|
|||
### 应用服务接口 |
|||
|
|||
* ITextTemplateDefinitionAppService |
|||
* GetAsync - 获取模板定义 |
|||
* GetListAsync - 获取模板定义列表 |
|||
* CreateAsync - 创建模板定义 |
|||
* UpdateAsync - 更新模板定义 |
|||
* DeleteAsync - 删除模板定义 |
|||
* ITextTemplateContentAppService |
|||
* GetAsync - 获取模板内容 |
|||
* UpdateAsync - 更新模板内容 |
|||
* DeleteAsync - 删除模板内容 |
|||
* RestoreAsync - 恢复模板内容 |
|||
|
|||
### 如何使用 |
|||
|
|||
1. 添加 `AbpTextTemplatingApplicationContractsModule` 依赖 |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpTextTemplatingApplicationContractsModule))] |
|||
public class YouProjectModule : AbpModule |
|||
{ |
|||
} |
|||
``` |
|||
|
|||
2. 注入并使用模板服务接口 |
|||
|
|||
```csharp |
|||
public class YourService |
|||
{ |
|||
private readonly ITextTemplateDefinitionAppService _templateDefinitionAppService; |
|||
|
|||
public YourService(ITextTemplateDefinitionAppService templateDefinitionAppService) |
|||
{ |
|||
_templateDefinitionAppService = templateDefinitionAppService; |
|||
} |
|||
|
|||
public async Task ManageTemplateAsync() |
|||
{ |
|||
// 获取模板定义列表 |
|||
var templates = await _templateDefinitionAppService.GetListAsync( |
|||
new TextTemplateDefinitionGetListInput()); |
|||
} |
|||
} |
|||
``` |
|||
|
|||
[查看英文](README.EN.md) |
|||
@ -0,0 +1,83 @@ |
|||
# LINGYUN.Abp.TextTemplating.Application |
|||
|
|||
## Module Description |
|||
|
|||
Text templating application service module, implementing management and operation functions for text templates. |
|||
|
|||
### Base Modules |
|||
|
|||
* LINGYUN.Abp.TextTemplating.Application.Contracts |
|||
* Volo.Abp.TextTemplating |
|||
* Volo.Abp.Ddd.Application |
|||
|
|||
### Features |
|||
|
|||
* Provides text template definition management services |
|||
* TextTemplateDefinitionAppService - Template definition management service |
|||
* TextTemplateContentAppService - Template content management service |
|||
* Implements the following application service interfaces |
|||
* ITextTemplateDefinitionAppService |
|||
* ITextTemplateContentAppService |
|||
|
|||
### Application Services |
|||
|
|||
* TextTemplateDefinitionAppService |
|||
* GetAsync - Get template definition |
|||
* GetListAsync - Get template definition list |
|||
* CreateAsync - Create template definition |
|||
* UpdateAsync - Update template definition |
|||
* DeleteAsync - Delete template definition |
|||
* TextTemplateContentAppService |
|||
* GetAsync - Get template content |
|||
* UpdateAsync - Update template content |
|||
* DeleteAsync - Delete template content |
|||
* RestoreAsync - Restore template content |
|||
|
|||
### Permissions |
|||
|
|||
* AbpTextTemplating.TextTemplateDefinitions |
|||
* Create - Create template definition |
|||
* Update - Update template definition |
|||
* Delete - Delete template definition |
|||
* AbpTextTemplating.TextTemplateContents |
|||
* Update - Update template content |
|||
* Delete - Delete template content |
|||
|
|||
### How to Use |
|||
|
|||
1. Add `AbpTextTemplatingApplicationModule` dependency |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpTextTemplatingApplicationModule))] |
|||
public class YouProjectModule : AbpModule |
|||
{ |
|||
} |
|||
``` |
|||
|
|||
2. Inject and use template services |
|||
|
|||
```csharp |
|||
public class YourService |
|||
{ |
|||
private readonly ITextTemplateDefinitionAppService _templateDefinitionAppService; |
|||
|
|||
public YourService(ITextTemplateDefinitionAppService templateDefinitionAppService) |
|||
{ |
|||
_templateDefinitionAppService = templateDefinitionAppService; |
|||
} |
|||
|
|||
public async Task ManageTemplateAsync() |
|||
{ |
|||
// Create template definition |
|||
var template = await _templateDefinitionAppService.CreateAsync( |
|||
new TextTemplateDefinitionCreateDto |
|||
{ |
|||
Name = "TemplateName", |
|||
DisplayName = "Template Display Name", |
|||
RenderEngine = "Razor" |
|||
}); |
|||
} |
|||
} |
|||
``` |
|||
|
|||
[查看中文](README.md) |
|||
@ -0,0 +1,83 @@ |
|||
# LINGYUN.Abp.TextTemplating.Application |
|||
|
|||
## 模块说明 |
|||
|
|||
文本模板应用服务模块,实现文本模板的管理和操作功能。 |
|||
|
|||
### 基础模块 |
|||
|
|||
* LINGYUN.Abp.TextTemplating.Application.Contracts |
|||
* Volo.Abp.TextTemplating |
|||
* Volo.Abp.Ddd.Application |
|||
|
|||
### 功能定义 |
|||
|
|||
* 提供文本模板定义管理服务 |
|||
* TextTemplateDefinitionAppService - 模板定义管理服务 |
|||
* TextTemplateContentAppService - 模板内容管理服务 |
|||
* 实现以下应用服务接口 |
|||
* ITextTemplateDefinitionAppService |
|||
* ITextTemplateContentAppService |
|||
|
|||
### 应用服务 |
|||
|
|||
* TextTemplateDefinitionAppService |
|||
* GetAsync - 获取模板定义 |
|||
* GetListAsync - 获取模板定义列表 |
|||
* CreateAsync - 创建模板定义 |
|||
* UpdateAsync - 更新模板定义 |
|||
* DeleteAsync - 删除模板定义 |
|||
* TextTemplateContentAppService |
|||
* GetAsync - 获取模板内容 |
|||
* UpdateAsync - 更新模板内容 |
|||
* DeleteAsync - 删除模板内容 |
|||
* RestoreAsync - 恢复模板内容 |
|||
|
|||
### 权限 |
|||
|
|||
* AbpTextTemplating.TextTemplateDefinitions |
|||
* Create - 创建模板定义 |
|||
* Update - 更新模板定义 |
|||
* Delete - 删除模板定义 |
|||
* AbpTextTemplating.TextTemplateContents |
|||
* Update - 更新模板内容 |
|||
* Delete - 删除模板内容 |
|||
|
|||
### 如何使用 |
|||
|
|||
1. 添加 `AbpTextTemplatingApplicationModule` 依赖 |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpTextTemplatingApplicationModule))] |
|||
public class YouProjectModule : AbpModule |
|||
{ |
|||
} |
|||
``` |
|||
|
|||
2. 注入并使用模板服务 |
|||
|
|||
```csharp |
|||
public class YourService |
|||
{ |
|||
private readonly ITextTemplateDefinitionAppService _templateDefinitionAppService; |
|||
|
|||
public YourService(ITextTemplateDefinitionAppService templateDefinitionAppService) |
|||
{ |
|||
_templateDefinitionAppService = templateDefinitionAppService; |
|||
} |
|||
|
|||
public async Task ManageTemplateAsync() |
|||
{ |
|||
// 创建模板定义 |
|||
var template = await _templateDefinitionAppService.CreateAsync( |
|||
new TextTemplateDefinitionCreateDto |
|||
{ |
|||
Name = "TemplateName", |
|||
DisplayName = "Template Display Name", |
|||
RenderEngine = "Razor" |
|||
}); |
|||
} |
|||
} |
|||
``` |
|||
|
|||
[查看英文](README.EN.md) |
|||
@ -0,0 +1,64 @@ |
|||
# LINGYUN.Abp.TextTemplating.Domain.Shared |
|||
|
|||
## Module Description |
|||
|
|||
Text templating domain shared module, providing shared definitions for text templates including constants, enums, and exceptions. |
|||
|
|||
### Base Modules |
|||
|
|||
* Volo.Abp.TextTemplating |
|||
* Volo.Abp.Validation |
|||
|
|||
### Features |
|||
|
|||
* Provides constants for text templates |
|||
* TextTemplateDefinitionConsts - Template definition related constants |
|||
* TextTemplateContentConsts - Template content related constants |
|||
* Provides error code definitions |
|||
* AbpTextTemplatingErrorCodes - Error code constants |
|||
* Provides localization resources |
|||
* AbpTextTemplatingResource - Localization resource |
|||
|
|||
### Constants |
|||
|
|||
* TextTemplateDefinitionConsts |
|||
* MaxNameLength - Maximum length for template name (64) |
|||
* MaxDisplayNameLength - Maximum length for display name (128) |
|||
* MaxLayoutLength - Maximum length for layout name (256) |
|||
* MaxDefaultCultureNameLength - Maximum length for default culture name (10) |
|||
* MaxLocalizationResourceNameLength - Maximum length for localization resource name (128) |
|||
* MaxRenderEngineLength - Maximum length for render engine name (64) |
|||
|
|||
### Error Codes |
|||
|
|||
* AbpTextTemplatingErrorCodes |
|||
* TextTemplateDefinition:NameAlreadyExists - Template name already exists |
|||
* TextTemplateDefinition:NotFound - Template definition not found |
|||
|
|||
### How to Use |
|||
|
|||
1. Add `AbpTextTemplatingDomainSharedModule` dependency |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpTextTemplatingDomainSharedModule))] |
|||
public class YouProjectModule : AbpModule |
|||
{ |
|||
} |
|||
``` |
|||
|
|||
2. Use constants and error codes |
|||
|
|||
```csharp |
|||
public class YourService |
|||
{ |
|||
public void ValidateTemplateName(string name) |
|||
{ |
|||
if (name.Length > TextTemplateDefinitionConsts.MaxNameLength) |
|||
{ |
|||
throw new BusinessException(AbpTextTemplatingErrorCodes.TextTemplateDefinition.NameAlreadyExists); |
|||
} |
|||
} |
|||
} |
|||
``` |
|||
|
|||
[查看中文](README.md) |
|||
@ -0,0 +1,64 @@ |
|||
# LINGYUN.Abp.TextTemplating.Domain.Shared |
|||
|
|||
## 模块说明 |
|||
|
|||
文本模板领域共享模块,提供文本模板相关的常量、枚举、异常等共享定义。 |
|||
|
|||
### 基础模块 |
|||
|
|||
* Volo.Abp.TextTemplating |
|||
* Volo.Abp.Validation |
|||
|
|||
### 功能定义 |
|||
|
|||
* 提供文本模板相关的常量定义 |
|||
* TextTemplateDefinitionConsts - 模板定义相关常量 |
|||
* TextTemplateContentConsts - 模板内容相关常量 |
|||
* 提供文本模板相关的错误代码定义 |
|||
* AbpTextTemplatingErrorCodes - 错误代码常量 |
|||
* 提供本地化资源定义 |
|||
* AbpTextTemplatingResource - 本地化资源 |
|||
|
|||
### 常量定义 |
|||
|
|||
* TextTemplateDefinitionConsts |
|||
* MaxNameLength - 模板名称最大长度 (64) |
|||
* MaxDisplayNameLength - 显示名称最大长度 (128) |
|||
* MaxLayoutLength - 布局名称最大长度 (256) |
|||
* MaxDefaultCultureNameLength - 默认文化名称最大长度 (10) |
|||
* MaxLocalizationResourceNameLength - 本地化资源名称最大长度 (128) |
|||
* MaxRenderEngineLength - 渲染引擎名称最大长度 (64) |
|||
|
|||
### 错误代码 |
|||
|
|||
* AbpTextTemplatingErrorCodes |
|||
* TextTemplateDefinition:NameAlreadyExists - 模板名称已存在 |
|||
* TextTemplateDefinition:NotFound - 模板定义不存在 |
|||
|
|||
### 如何使用 |
|||
|
|||
1. 添加 `AbpTextTemplatingDomainSharedModule` 依赖 |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpTextTemplatingDomainSharedModule))] |
|||
public class YouProjectModule : AbpModule |
|||
{ |
|||
} |
|||
``` |
|||
|
|||
2. 使用常量和错误代码 |
|||
|
|||
```csharp |
|||
public class YourService |
|||
{ |
|||
public void ValidateTemplateName(string name) |
|||
{ |
|||
if (name.Length > TextTemplateDefinitionConsts.MaxNameLength) |
|||
{ |
|||
throw new BusinessException(AbpTextTemplatingErrorCodes.TextTemplateDefinition.NameAlreadyExists); |
|||
} |
|||
} |
|||
} |
|||
``` |
|||
|
|||
[查看英文](README.EN.md) |
|||
@ -0,0 +1,82 @@ |
|||
# LINGYUN.Abp.TextTemplating.Domain |
|||
|
|||
## Module Description |
|||
|
|||
Text templating domain module, providing core functionality for text template definition and content management. |
|||
|
|||
### Base Modules |
|||
|
|||
* Volo.Abp.TextTemplating |
|||
* Volo.Abp.Ddd.Domain |
|||
|
|||
### Features |
|||
|
|||
* Provides domain entities for text template definition |
|||
* TextTemplateDefinition - Text template definition entity |
|||
* TextTemplateContent - Text template content entity |
|||
* Provides repository interfaces for text template definition |
|||
* ITextTemplateDefinitionRepository - Text template definition repository interface |
|||
* ITextTemplateContentRepository - Text template content repository interface |
|||
* Provides domain services for text template management |
|||
* TextTemplateManager - Text template manager |
|||
* IStaticTemplateDefinitionStore - Static template definition store |
|||
* IDynamicTemplateDefinitionStore - Dynamic template definition store |
|||
|
|||
### Domain Services |
|||
|
|||
* TextTemplateManager |
|||
* Manages creation, update, and deletion of text templates |
|||
* Handles association between template definitions and content |
|||
* Supports management of both static and dynamic template definitions |
|||
|
|||
### Entity Properties |
|||
|
|||
* TextTemplateDefinition |
|||
* Name - Template name |
|||
* DisplayName - Display name |
|||
* IsLayout - Whether it is a layout template |
|||
* Layout - Layout name |
|||
* IsInlineLocalized - Whether inline localization is enabled |
|||
* DefaultCultureName - Default culture name |
|||
* LocalizationResourceName - Localization resource name |
|||
* RenderEngine - Render engine |
|||
* IsStatic - Whether it is a static template |
|||
|
|||
### How to Use |
|||
|
|||
1. Add `AbpTextTemplatingDomainModule` dependency |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpTextTemplatingDomainModule))] |
|||
public class YouProjectModule : AbpModule |
|||
{ |
|||
} |
|||
``` |
|||
|
|||
2. Use text template manager |
|||
|
|||
```csharp |
|||
public class YourService |
|||
{ |
|||
private readonly TextTemplateManager _templateManager; |
|||
|
|||
public YourService(TextTemplateManager templateManager) |
|||
{ |
|||
_templateManager = templateManager; |
|||
} |
|||
|
|||
public async Task ManageTemplateAsync() |
|||
{ |
|||
// Create template definition |
|||
var template = new TextTemplateDefinition( |
|||
Guid.NewGuid(), |
|||
"TemplateName", |
|||
"Template Display Name", |
|||
renderEngine: "Razor"); |
|||
|
|||
await _templateManager.CreateAsync(template); |
|||
} |
|||
} |
|||
``` |
|||
|
|||
[查看中文](README.md) |
|||
@ -0,0 +1,82 @@ |
|||
# LINGYUN.Abp.TextTemplating.Domain |
|||
|
|||
## 模块说明 |
|||
|
|||
文本模板领域模块,提供文本模板定义和内容管理的核心功能。 |
|||
|
|||
### 基础模块 |
|||
|
|||
* Volo.Abp.TextTemplating |
|||
* Volo.Abp.Ddd.Domain |
|||
|
|||
### 功能定义 |
|||
|
|||
* 提供文本模板定义的领域实体 |
|||
* TextTemplateDefinition - 文本模板定义实体 |
|||
* TextTemplateContent - 文本模板内容实体 |
|||
* 提供文本模板定义的仓储接口 |
|||
* ITextTemplateDefinitionRepository - 文本模板定义仓储接口 |
|||
* ITextTemplateContentRepository - 文本模板内容仓储接口 |
|||
* 提供文本模板管理的领域服务 |
|||
* TextTemplateManager - 文本模板管理器 |
|||
* IStaticTemplateDefinitionStore - 静态模板定义存储 |
|||
* IDynamicTemplateDefinitionStore - 动态模板定义存储 |
|||
|
|||
### 领域服务 |
|||
|
|||
* TextTemplateManager |
|||
* 管理文本模板的创建、更新、删除 |
|||
* 处理模板定义与内容的关联 |
|||
* 支持静态和动态模板定义的管理 |
|||
|
|||
### 实体属性 |
|||
|
|||
* TextTemplateDefinition |
|||
* Name - 模板名称 |
|||
* DisplayName - 显示名称 |
|||
* IsLayout - 是否为布局模板 |
|||
* Layout - 布局名称 |
|||
* IsInlineLocalized - 是否内联本地化 |
|||
* DefaultCultureName - 默认文化名称 |
|||
* LocalizationResourceName - 本地化资源名称 |
|||
* RenderEngine - 渲染引擎 |
|||
* IsStatic - 是否为静态模板 |
|||
|
|||
### 如何使用 |
|||
|
|||
1. 添加 `AbpTextTemplatingDomainModule` 依赖 |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpTextTemplatingDomainModule))] |
|||
public class YouProjectModule : AbpModule |
|||
{ |
|||
} |
|||
``` |
|||
|
|||
2. 使用文本模板管理器 |
|||
|
|||
```csharp |
|||
public class YourService |
|||
{ |
|||
private readonly TextTemplateManager _templateManager; |
|||
|
|||
public YourService(TextTemplateManager templateManager) |
|||
{ |
|||
_templateManager = templateManager; |
|||
} |
|||
|
|||
public async Task ManageTemplateAsync() |
|||
{ |
|||
// 创建模板定义 |
|||
var template = new TextTemplateDefinition( |
|||
Guid.NewGuid(), |
|||
"TemplateName", |
|||
"Template Display Name", |
|||
renderEngine: "Razor"); |
|||
|
|||
await _templateManager.CreateAsync(template); |
|||
} |
|||
} |
|||
``` |
|||
|
|||
[查看英文](README.EN.md) |
|||
@ -0,0 +1,74 @@ |
|||
# LINGYUN.Abp.TextTemplating.EntityFrameworkCore |
|||
|
|||
## Module Description |
|||
|
|||
Text templating EntityFrameworkCore module, providing data access implementation for text templates. |
|||
|
|||
### Base Modules |
|||
|
|||
* LINGYUN.Abp.TextTemplating.Domain |
|||
* Volo.Abp.EntityFrameworkCore |
|||
|
|||
### Features |
|||
|
|||
* Implements repository interfaces for text templates |
|||
* EfCoreTextTemplateDefinitionRepository - Template definition repository implementation |
|||
* EfCoreTextTemplateContentRepository - Template content repository implementation |
|||
* Provides database context and configuration |
|||
* ITextTemplatingDbContext - Text templating database context interface |
|||
* TextTemplatingDbContext - Text templating database context |
|||
* TextTemplatingDbContextModelCreatingExtensions - Database model configuration extensions |
|||
|
|||
### Database Tables |
|||
|
|||
* AbpTextTemplateDefinitions - Template definition table |
|||
* Id - Primary key |
|||
* Name - Template name |
|||
* DisplayName - Display name |
|||
* IsLayout - Whether it is a layout template |
|||
* Layout - Layout name |
|||
* IsInlineLocalized - Whether inline localization is enabled |
|||
* DefaultCultureName - Default culture name |
|||
* LocalizationResourceName - Localization resource name |
|||
* RenderEngine - Render engine |
|||
* IsStatic - Whether it is a static template |
|||
* AbpTextTemplateContents - Template content table |
|||
* Id - Primary key |
|||
* Name - Template name |
|||
* CultureName - Culture name |
|||
* Content - Template content |
|||
|
|||
### How to Use |
|||
|
|||
1. Add `AbpTextTemplatingEntityFrameworkCoreModule` dependency |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpTextTemplatingEntityFrameworkCoreModule))] |
|||
public class YouProjectModule : AbpModule |
|||
{ |
|||
} |
|||
``` |
|||
|
|||
2. Configure database context |
|||
|
|||
```csharp |
|||
public class YourDbContext : AbpDbContext<YourDbContext>, ITextTemplatingDbContext |
|||
{ |
|||
public DbSet<TextTemplateDefinition> TextTemplateDefinitions { get; set; } |
|||
public DbSet<TextTemplateContent> TextTemplateContents { get; set; } |
|||
|
|||
public YourDbContext(DbContextOptions<YourDbContext> options) |
|||
: base(options) |
|||
{ |
|||
} |
|||
|
|||
protected override void OnModelCreating(ModelBuilder builder) |
|||
{ |
|||
base.OnModelCreating(builder); |
|||
|
|||
builder.ConfigureTextTemplating(); |
|||
} |
|||
} |
|||
``` |
|||
|
|||
[查看中文](README.md) |
|||
@ -0,0 +1,74 @@ |
|||
# LINGYUN.Abp.TextTemplating.EntityFrameworkCore |
|||
|
|||
## 模块说明 |
|||
|
|||
文本模板 EntityFrameworkCore 模块,提供文本模板的数据访问实现。 |
|||
|
|||
### 基础模块 |
|||
|
|||
* LINGYUN.Abp.TextTemplating.Domain |
|||
* Volo.Abp.EntityFrameworkCore |
|||
|
|||
### 功能定义 |
|||
|
|||
* 实现文本模板的仓储接口 |
|||
* EfCoreTextTemplateDefinitionRepository - 模板定义仓储实现 |
|||
* EfCoreTextTemplateContentRepository - 模板内容仓储实现 |
|||
* 提供数据库上下文和配置 |
|||
* ITextTemplatingDbContext - 文本模板数据库上下文接口 |
|||
* TextTemplatingDbContext - 文本模板数据库上下文 |
|||
* TextTemplatingDbContextModelCreatingExtensions - 数据库模型配置扩展 |
|||
|
|||
### 数据库表 |
|||
|
|||
* AbpTextTemplateDefinitions - 模板定义表 |
|||
* Id - 主键 |
|||
* Name - 模板名称 |
|||
* DisplayName - 显示名称 |
|||
* IsLayout - 是否为布局模板 |
|||
* Layout - 布局名称 |
|||
* IsInlineLocalized - 是否内联本地化 |
|||
* DefaultCultureName - 默认文化名称 |
|||
* LocalizationResourceName - 本地化资源名称 |
|||
* RenderEngine - 渲染引擎 |
|||
* IsStatic - 是否为静态模板 |
|||
* AbpTextTemplateContents - 模板内容表 |
|||
* Id - 主键 |
|||
* Name - 模板名称 |
|||
* CultureName - 文化名称 |
|||
* Content - 模板内容 |
|||
|
|||
### 如何使用 |
|||
|
|||
1. 添加 `AbpTextTemplatingEntityFrameworkCoreModule` 依赖 |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpTextTemplatingEntityFrameworkCoreModule))] |
|||
public class YouProjectModule : AbpModule |
|||
{ |
|||
} |
|||
``` |
|||
|
|||
2. 配置数据库上下文 |
|||
|
|||
```csharp |
|||
public class YourDbContext : AbpDbContext<YourDbContext>, ITextTemplatingDbContext |
|||
{ |
|||
public DbSet<TextTemplateDefinition> TextTemplateDefinitions { get; set; } |
|||
public DbSet<TextTemplateContent> TextTemplateContents { get; set; } |
|||
|
|||
public YourDbContext(DbContextOptions<YourDbContext> options) |
|||
: base(options) |
|||
{ |
|||
} |
|||
|
|||
protected override void OnModelCreating(ModelBuilder builder) |
|||
{ |
|||
base.OnModelCreating(builder); |
|||
|
|||
builder.ConfigureTextTemplating(); |
|||
} |
|||
} |
|||
``` |
|||
|
|||
[查看英文](README.EN.md) |
|||
@ -0,0 +1,66 @@ |
|||
# LINGYUN.Abp.TextTemplating.HttpApi.Client |
|||
|
|||
## Module Description |
|||
|
|||
Text templating HTTP API client module, providing HTTP client proxy implementation for text template management. |
|||
|
|||
### Base Modules |
|||
|
|||
* LINGYUN.Abp.TextTemplating.Application.Contracts |
|||
* Volo.Abp.Http.Client |
|||
|
|||
### Features |
|||
|
|||
* Provides HTTP client proxies for text template management |
|||
* TextTemplateDefinitionClientProxy - Template definition management client proxy |
|||
* TextTemplateContentClientProxy - Template content management client proxy |
|||
* Implements the following application service interfaces |
|||
* ITextTemplateDefinitionAppService |
|||
* ITextTemplateContentAppService |
|||
|
|||
### Configuration |
|||
|
|||
* AbpTextTemplatingRemoteServiceConsts |
|||
* RemoteServiceName - Remote service name (default: "AbpTextTemplating") |
|||
|
|||
### How to Use |
|||
|
|||
1. Add `AbpTextTemplatingHttpApiClientModule` dependency |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpTextTemplatingHttpApiClientModule))] |
|||
public class YouProjectModule : AbpModule |
|||
{ |
|||
public override void ConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
// Configure remote service |
|||
Configure<AbpRemoteServiceOptions>(options => |
|||
{ |
|||
options.RemoteServices.Default.BaseUrl = "http://localhost:44315/"; |
|||
}); |
|||
} |
|||
} |
|||
``` |
|||
|
|||
2. Inject and use client proxies |
|||
|
|||
```csharp |
|||
public class YourService |
|||
{ |
|||
private readonly ITextTemplateDefinitionAppService _templateDefinitionAppService; |
|||
|
|||
public YourService(ITextTemplateDefinitionAppService templateDefinitionAppService) |
|||
{ |
|||
_templateDefinitionAppService = templateDefinitionAppService; |
|||
} |
|||
|
|||
public async Task ManageTemplateAsync() |
|||
{ |
|||
// Get template definition list |
|||
var templates = await _templateDefinitionAppService.GetListAsync( |
|||
new TextTemplateDefinitionGetListInput()); |
|||
} |
|||
} |
|||
``` |
|||
|
|||
[查看中文](README.md) |
|||
@ -0,0 +1,66 @@ |
|||
# LINGYUN.Abp.TextTemplating.HttpApi.Client |
|||
|
|||
## 模块说明 |
|||
|
|||
文本模板 HTTP API 客户端模块,提供文本模板管理的 HTTP 客户端代理实现。 |
|||
|
|||
### 基础模块 |
|||
|
|||
* LINGYUN.Abp.TextTemplating.Application.Contracts |
|||
* Volo.Abp.Http.Client |
|||
|
|||
### 功能定义 |
|||
|
|||
* 提供文本模板管理的 HTTP 客户端代理 |
|||
* TextTemplateDefinitionClientProxy - 模板定义管理客户端代理 |
|||
* TextTemplateContentClientProxy - 模板内容管理客户端代理 |
|||
* 实现以下应用服务接口 |
|||
* ITextTemplateDefinitionAppService |
|||
* ITextTemplateContentAppService |
|||
|
|||
### 配置项 |
|||
|
|||
* AbpTextTemplatingRemoteServiceConsts |
|||
* RemoteServiceName - 远程服务名称 (默认: "AbpTextTemplating") |
|||
|
|||
### 如何使用 |
|||
|
|||
1. 添加 `AbpTextTemplatingHttpApiClientModule` 依赖 |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpTextTemplatingHttpApiClientModule))] |
|||
public class YouProjectModule : AbpModule |
|||
{ |
|||
public override void ConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
// 配置远程服务 |
|||
Configure<AbpRemoteServiceOptions>(options => |
|||
{ |
|||
options.RemoteServices.Default.BaseUrl = "http://localhost:44315/"; |
|||
}); |
|||
} |
|||
} |
|||
``` |
|||
|
|||
2. 注入并使用客户端代理 |
|||
|
|||
```csharp |
|||
public class YourService |
|||
{ |
|||
private readonly ITextTemplateDefinitionAppService _templateDefinitionAppService; |
|||
|
|||
public YourService(ITextTemplateDefinitionAppService templateDefinitionAppService) |
|||
{ |
|||
_templateDefinitionAppService = templateDefinitionAppService; |
|||
} |
|||
|
|||
public async Task ManageTemplateAsync() |
|||
{ |
|||
// 获取模板定义列表 |
|||
var templates = await _templateDefinitionAppService.GetListAsync( |
|||
new TextTemplateDefinitionGetListInput()); |
|||
} |
|||
} |
|||
``` |
|||
|
|||
[查看英文](README.EN.md) |
|||
@ -0,0 +1,74 @@ |
|||
# LINGYUN.Abp.TextTemplating.HttpApi |
|||
|
|||
## Module Description |
|||
|
|||
Text templating HTTP API module, providing RESTful API interfaces for text template management. |
|||
|
|||
### Base Modules |
|||
|
|||
* LINGYUN.Abp.TextTemplating.Application.Contracts |
|||
* Volo.Abp.AspNetCore.Mvc |
|||
|
|||
### Features |
|||
|
|||
* Provides API controllers for text template management |
|||
* TextTemplateDefinitionController - Template definition management controller |
|||
* TextTemplateContentController - Template content management controller |
|||
|
|||
### API Endpoints |
|||
|
|||
* /api/text-templating/template-definitions |
|||
* GET - Get template definition list |
|||
* POST - Create template definition |
|||
* PUT - Update template definition |
|||
* DELETE - Delete template definition |
|||
* GET /{name} - Get specific template definition |
|||
* /api/text-templating/template-contents |
|||
* GET - Get template content |
|||
* PUT - Update template content |
|||
* DELETE - Delete template content |
|||
* POST /restore - Restore template content |
|||
|
|||
### Permission Requirements |
|||
|
|||
* AbpTextTemplating.TextTemplateDefinitions |
|||
* Create - Create template definition |
|||
* Update - Update template definition |
|||
* Delete - Delete template definition |
|||
* AbpTextTemplating.TextTemplateContents |
|||
* Update - Update template content |
|||
* Delete - Delete template content |
|||
|
|||
### How to Use |
|||
|
|||
1. Add `AbpTextTemplatingHttpApiModule` dependency |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpTextTemplatingHttpApiModule))] |
|||
public class YouProjectModule : AbpModule |
|||
{ |
|||
} |
|||
``` |
|||
|
|||
2. Use API endpoints |
|||
|
|||
```csharp |
|||
public class YourService |
|||
{ |
|||
private readonly HttpClient _httpClient; |
|||
|
|||
public YourService(HttpClient httpClient) |
|||
{ |
|||
_httpClient = httpClient; |
|||
} |
|||
|
|||
public async Task ManageTemplateAsync() |
|||
{ |
|||
// Get template definition list |
|||
var response = await _httpClient.GetAsync("/api/text-templating/template-definitions"); |
|||
var templates = await response.Content.ReadFromJsonAsync<ListResultDto<TextTemplateDefinitionDto>>(); |
|||
} |
|||
} |
|||
``` |
|||
|
|||
[查看中文](README.md) |
|||
@ -0,0 +1,74 @@ |
|||
# LINGYUN.Abp.TextTemplating.HttpApi |
|||
|
|||
## 模块说明 |
|||
|
|||
文本模板 HTTP API 模块,提供文本模板管理的 RESTful API 接口。 |
|||
|
|||
### 基础模块 |
|||
|
|||
* LINGYUN.Abp.TextTemplating.Application.Contracts |
|||
* Volo.Abp.AspNetCore.Mvc |
|||
|
|||
### 功能定义 |
|||
|
|||
* 提供文本模板管理的 API 控制器 |
|||
* TextTemplateDefinitionController - 模板定义管理控制器 |
|||
* TextTemplateContentController - 模板内容管理控制器 |
|||
|
|||
### API 接口 |
|||
|
|||
* /api/text-templating/template-definitions |
|||
* GET - 获取模板定义列表 |
|||
* POST - 创建模板定义 |
|||
* PUT - 更新模板定义 |
|||
* DELETE - 删除模板定义 |
|||
* GET /{name} - 获取指定模板定义 |
|||
* /api/text-templating/template-contents |
|||
* GET - 获取模板内容 |
|||
* PUT - 更新模板内容 |
|||
* DELETE - 删除模板内容 |
|||
* POST /restore - 恢复模板内容 |
|||
|
|||
### 权限要求 |
|||
|
|||
* AbpTextTemplating.TextTemplateDefinitions |
|||
* Create - 创建模板定义 |
|||
* Update - 更新模板定义 |
|||
* Delete - 删除模板定义 |
|||
* AbpTextTemplating.TextTemplateContents |
|||
* Update - 更新模板内容 |
|||
* Delete - 删除模板内容 |
|||
|
|||
### 如何使用 |
|||
|
|||
1. 添加 `AbpTextTemplatingHttpApiModule` 依赖 |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpTextTemplatingHttpApiModule))] |
|||
public class YouProjectModule : AbpModule |
|||
{ |
|||
} |
|||
``` |
|||
|
|||
2. 使用 API 接口 |
|||
|
|||
```csharp |
|||
public class YourService |
|||
{ |
|||
private readonly HttpClient _httpClient; |
|||
|
|||
public YourService(HttpClient httpClient) |
|||
{ |
|||
_httpClient = httpClient; |
|||
} |
|||
|
|||
public async Task ManageTemplateAsync() |
|||
{ |
|||
// 获取模板定义列表 |
|||
var response = await _httpClient.GetAsync("/api/text-templating/template-definitions"); |
|||
var templates = await response.Content.ReadFromJsonAsync<ListResultDto<TextTemplateDefinitionDto>>(); |
|||
} |
|||
} |
|||
``` |
|||
|
|||
[查看英文](README.EN.md) |
|||
@ -0,0 +1,87 @@ |
|||
# LINGYUN.Abp.TextTemplating.Razor |
|||
|
|||
## Module Description |
|||
|
|||
Text templating Razor engine module, providing template rendering implementation based on Razor syntax. |
|||
|
|||
### Base Modules |
|||
|
|||
* Volo.Abp.TextTemplating.Razor |
|||
* LINGYUN.Abp.TextTemplating.Domain |
|||
|
|||
### Features |
|||
|
|||
* Provides Razor template rendering engine |
|||
* RazorTemplateRenderingEngine - Razor template rendering engine implementation |
|||
* Supports the following features |
|||
* Write templates using Razor syntax |
|||
* Support model binding and strongly-typed views |
|||
* Support layout templates |
|||
* Support partial views |
|||
* Support HTML encoding and decoding |
|||
* Support conditional statements and loops |
|||
* Support C# expressions |
|||
|
|||
### How to Use |
|||
|
|||
1. Add `AbpTextTemplatingRazorModule` dependency |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpTextTemplatingRazorModule))] |
|||
public class YouProjectModule : AbpModule |
|||
{ |
|||
} |
|||
``` |
|||
|
|||
2. Create and use Razor templates |
|||
|
|||
```csharp |
|||
// Create template definition |
|||
var template = new TextTemplateDefinition( |
|||
Guid.NewGuid(), |
|||
"Welcome", |
|||
"Welcome Email Template", |
|||
renderEngine: "Razor"); |
|||
|
|||
// Template content example |
|||
@model WelcomeEmailModel |
|||
|
|||
<!DOCTYPE html> |
|||
<html> |
|||
<body> |
|||
<h1>Welcome @Model.UserName!</h1> |
|||
<p>Thank you for joining us.</p> |
|||
@if (Model.IsFirstTime) |
|||
{ |
|||
<p>Here are some tips to get started...</p> |
|||
} |
|||
</body> |
|||
</html> |
|||
|
|||
// Use template |
|||
public class YourService |
|||
{ |
|||
private readonly ITemplateRenderer _templateRenderer; |
|||
|
|||
public YourService(ITemplateRenderer templateRenderer) |
|||
{ |
|||
_templateRenderer = templateRenderer; |
|||
} |
|||
|
|||
public async Task<string> RenderWelcomeEmailAsync(string userName, bool isFirstTime) |
|||
{ |
|||
var model = new WelcomeEmailModel |
|||
{ |
|||
UserName = userName, |
|||
IsFirstTime = isFirstTime |
|||
}; |
|||
|
|||
return await _templateRenderer.RenderAsync( |
|||
"Welcome", |
|||
model |
|||
); |
|||
} |
|||
} |
|||
``` |
|||
|
|||
[查看中文](README.md) |
|||
@ -0,0 +1,87 @@ |
|||
# LINGYUN.Abp.TextTemplating.Razor |
|||
|
|||
## 模块说明 |
|||
|
|||
文本模板 Razor 引擎模块,提供基于 Razor 语法的模板渲染实现。 |
|||
|
|||
### 基础模块 |
|||
|
|||
* Volo.Abp.TextTemplating.Razor |
|||
* LINGYUN.Abp.TextTemplating.Domain |
|||
|
|||
### 功能定义 |
|||
|
|||
* 提供 Razor 模板渲染引擎 |
|||
* RazorTemplateRenderingEngine - Razor 模板渲染引擎实现 |
|||
* 支持以下功能 |
|||
* 使用 Razor 语法编写模板 |
|||
* 支持模型绑定和强类型视图 |
|||
* 支持布局模板 |
|||
* 支持部分视图 |
|||
* 支持 HTML 编码和解码 |
|||
* 支持条件语句和循环 |
|||
* 支持 C# 表达式 |
|||
|
|||
### 如何使用 |
|||
|
|||
1. 添加 `AbpTextTemplatingRazorModule` 依赖 |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpTextTemplatingRazorModule))] |
|||
public class YouProjectModule : AbpModule |
|||
{ |
|||
} |
|||
``` |
|||
|
|||
2. 创建和使用 Razor 模板 |
|||
|
|||
```csharp |
|||
// 创建模板定义 |
|||
var template = new TextTemplateDefinition( |
|||
Guid.NewGuid(), |
|||
"Welcome", |
|||
"Welcome Email Template", |
|||
renderEngine: "Razor"); |
|||
|
|||
// 模板内容示例 |
|||
@model WelcomeEmailModel |
|||
|
|||
<!DOCTYPE html> |
|||
<html> |
|||
<body> |
|||
<h1>Welcome @Model.UserName!</h1> |
|||
<p>Thank you for joining us.</p> |
|||
@if (Model.IsFirstTime) |
|||
{ |
|||
<p>Here are some tips to get started...</p> |
|||
} |
|||
</body> |
|||
</html> |
|||
|
|||
// 使用模板 |
|||
public class YourService |
|||
{ |
|||
private readonly ITemplateRenderer _templateRenderer; |
|||
|
|||
public YourService(ITemplateRenderer templateRenderer) |
|||
{ |
|||
_templateRenderer = templateRenderer; |
|||
} |
|||
|
|||
public async Task<string> RenderWelcomeEmailAsync(string userName, bool isFirstTime) |
|||
{ |
|||
var model = new WelcomeEmailModel |
|||
{ |
|||
UserName = userName, |
|||
IsFirstTime = isFirstTime |
|||
}; |
|||
|
|||
return await _templateRenderer.RenderAsync( |
|||
"Welcome", |
|||
model |
|||
); |
|||
} |
|||
} |
|||
``` |
|||
|
|||
[查看英文](README.EN.md) |
|||
@ -0,0 +1,93 @@ |
|||
# LINGYUN.Abp.TextTemplating.Scriban |
|||
|
|||
## Module Description |
|||
|
|||
Text templating Scriban engine module, providing template rendering implementation based on Scriban syntax. |
|||
|
|||
### Base Modules |
|||
|
|||
* Volo.Abp.TextTemplating.Scriban |
|||
* LINGYUN.Abp.TextTemplating.Domain |
|||
|
|||
### Features |
|||
|
|||
* Provides Scriban template rendering engine |
|||
* ScribanTemplateRenderingEngine - Scriban template rendering engine implementation |
|||
* Supports the following features |
|||
* Write templates using Scriban syntax |
|||
* Support model binding |
|||
* Support layout templates |
|||
* Support conditional statements and loops |
|||
* Support custom functions and filters |
|||
* Support string operations and formatting |
|||
* Support array and object operations |
|||
|
|||
### How to Use |
|||
|
|||
1. Add `AbpTextTemplatingScribanModule` dependency |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpTextTemplatingScribanModule))] |
|||
public class YouProjectModule : AbpModule |
|||
{ |
|||
} |
|||
``` |
|||
|
|||
2. Create and use Scriban templates |
|||
|
|||
```csharp |
|||
// Create template definition |
|||
var template = new TextTemplateDefinition( |
|||
Guid.NewGuid(), |
|||
"Welcome", |
|||
"Welcome Email Template", |
|||
renderEngine: "Scriban"); |
|||
|
|||
// Template content example |
|||
<!DOCTYPE html> |
|||
<html> |
|||
<body> |
|||
<h1>Welcome {{ user.name }}!</h1> |
|||
<p>Thank you for joining us.</p> |
|||
{{ if is_first_time }} |
|||
<p>Here are some tips to get started...</p> |
|||
{{ end }} |
|||
<ul> |
|||
{{ for item in items }} |
|||
<li>{{ item.name }}: {{ item.description }}</li> |
|||
{{ end }} |
|||
</ul> |
|||
</body> |
|||
</html> |
|||
|
|||
// Use template |
|||
public class YourService |
|||
{ |
|||
private readonly ITemplateRenderer _templateRenderer; |
|||
|
|||
public YourService(ITemplateRenderer templateRenderer) |
|||
{ |
|||
_templateRenderer = templateRenderer; |
|||
} |
|||
|
|||
public async Task<string> RenderWelcomeEmailAsync( |
|||
string userName, |
|||
bool isFirstTime, |
|||
List<Item> items) |
|||
{ |
|||
var model = new Dictionary<string, object> |
|||
{ |
|||
["user"] = new { name = userName }, |
|||
["is_first_time"] = isFirstTime, |
|||
["items"] = items |
|||
}; |
|||
|
|||
return await _templateRenderer.RenderAsync( |
|||
"Welcome", |
|||
model |
|||
); |
|||
} |
|||
} |
|||
``` |
|||
|
|||
[查看中文](README.md) |
|||
@ -0,0 +1,93 @@ |
|||
# LINGYUN.Abp.TextTemplating.Scriban |
|||
|
|||
## 模块说明 |
|||
|
|||
文本模板 Scriban 引擎模块,提供基于 Scriban 语法的模板渲染实现。 |
|||
|
|||
### 基础模块 |
|||
|
|||
* Volo.Abp.TextTemplating.Scriban |
|||
* LINGYUN.Abp.TextTemplating.Domain |
|||
|
|||
### 功能定义 |
|||
|
|||
* 提供 Scriban 模板渲染引擎 |
|||
* ScribanTemplateRenderingEngine - Scriban 模板渲染引擎实现 |
|||
* 支持以下功能 |
|||
* 使用 Scriban 语法编写模板 |
|||
* 支持模型绑定 |
|||
* 支持布局模板 |
|||
* 支持条件语句和循环 |
|||
* 支持自定义函数和过滤器 |
|||
* 支持字符串操作和格式化 |
|||
* 支持数组和对象操作 |
|||
|
|||
### 如何使用 |
|||
|
|||
1. 添加 `AbpTextTemplatingScribanModule` 依赖 |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpTextTemplatingScribanModule))] |
|||
public class YouProjectModule : AbpModule |
|||
{ |
|||
} |
|||
``` |
|||
|
|||
2. 创建和使用 Scriban 模板 |
|||
|
|||
```csharp |
|||
// 创建模板定义 |
|||
var template = new TextTemplateDefinition( |
|||
Guid.NewGuid(), |
|||
"Welcome", |
|||
"Welcome Email Template", |
|||
renderEngine: "Scriban"); |
|||
|
|||
// 模板内容示例 |
|||
<!DOCTYPE html> |
|||
<html> |
|||
<body> |
|||
<h1>Welcome {{ user.name }}!</h1> |
|||
<p>Thank you for joining us.</p> |
|||
{{ if is_first_time }} |
|||
<p>Here are some tips to get started...</p> |
|||
{{ end }} |
|||
<ul> |
|||
{{ for item in items }} |
|||
<li>{{ item.name }}: {{ item.description }}</li> |
|||
{{ end }} |
|||
</ul> |
|||
</body> |
|||
</html> |
|||
|
|||
// 使用模板 |
|||
public class YourService |
|||
{ |
|||
private readonly ITemplateRenderer _templateRenderer; |
|||
|
|||
public YourService(ITemplateRenderer templateRenderer) |
|||
{ |
|||
_templateRenderer = templateRenderer; |
|||
} |
|||
|
|||
public async Task<string> RenderWelcomeEmailAsync( |
|||
string userName, |
|||
bool isFirstTime, |
|||
List<Item> items) |
|||
{ |
|||
var model = new Dictionary<string, object> |
|||
{ |
|||
["user"] = new { name = userName }, |
|||
["is_first_time"] = isFirstTime, |
|||
["items"] = items |
|||
}; |
|||
|
|||
return await _templateRenderer.RenderAsync( |
|||
"Welcome", |
|||
model |
|||
); |
|||
} |
|||
} |
|||
``` |
|||
|
|||
[查看英文](README.EN.md) |
|||
Loading…
Reference in new issue