Skip to content

Commit 1ed129c

Browse files
authored
Merge pull request #13 from jupre003/develop
v1.1.0
2 parents 220be79 + f97f521 commit 1ed129c

44 files changed

Lines changed: 4373 additions & 649 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/BuildFromDevelop.yml

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,22 @@ on:
99
jobs:
1010
build:
1111

12-
runs-on: windows-latest
12+
strategy:
13+
matrix:
14+
os: [ubuntu-latest, windows-latest]
15+
runs-on: ${{ matrix.os }}
1316

1417
steps:
15-
- uses: actions/checkout@v2
16-
- name: Setup .NET Core
17-
uses: actions/setup-dotnet@v1
18+
- uses: actions/checkout@v4
19+
- name: Setup .NET
20+
uses: actions/setup-dotnet@v4
1821
with:
19-
dotnet-version: 7.x
20-
- name: Install dependencies
21-
run: dotnet restore
22+
dotnet-version: 8.0.x
23+
# Disable package cache to avoid lock file requirement
24+
cache: false
25+
- name: Restore
26+
run: dotnet restore MbSoftLab.TemplateEngine.Core.sln
2227
- name: Build
23-
run: dotnet build --configuration Release --no-restore
28+
run: dotnet build MbSoftLab.TemplateEngine.Core.sln --configuration Release --no-restore
2429
- name: Test
25-
run: dotnet test --no-restore --verbosity normal
30+
run: dotnet test MbSoftLab.TemplateEngine.Core.sln --no-restore --verbosity normal

.github/workflows/BuildFromMaster.yml

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,21 @@ on:
99
jobs:
1010
build:
1111

12-
runs-on: windows-latest
12+
strategy:
13+
matrix:
14+
os: [ubuntu-latest, windows-latest]
15+
runs-on: ${{ matrix.os }}
1316

1417
steps:
15-
- uses: actions/checkout@v2
16-
- name: Setup .NET Core
17-
uses: actions/setup-dotnet@v1
18+
- uses: actions/checkout@v4
19+
- name: Setup .NET
20+
uses: actions/setup-dotnet@v4
1821
with:
19-
dotnet-version: 7.x
20-
- name: Install dependencies
21-
run: dotnet restore
22+
dotnet-version: 8.0.x
23+
cache: false
24+
- name: Restore
25+
run: dotnet restore MbSoftLab.TemplateEngine.Core.sln
2226
- name: Build
23-
run: dotnet build --configuration Release --no-restore
27+
run: dotnet build MbSoftLab.TemplateEngine.Core.sln --configuration Release --no-restore
2428
- name: Test
25-
run: dotnet test --no-restore --verbosity normal
29+
run: dotnet test MbSoftLab.TemplateEngine.Core.sln --no-restore --verbosity normal

.github/workflows/Release.yml

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,17 @@ jobs:
99
publish-nuget:
1010
runs-on: windows-latest
1111
steps:
12-
- uses: actions/checkout@v2
13-
- name: Setup .NET Core
14-
uses: actions/setup-dotnet@v1
12+
- uses: actions/checkout@v4
13+
- name: Setup .NET
14+
uses: actions/setup-dotnet@v4
1515
with:
16-
dotnet-version: 7.x
17-
- name: Install dependencies
18-
run: dotnet restore
16+
dotnet-version: 8.0.x
17+
cache: false
18+
- name: Restore
19+
run: dotnet restore MbSoftLab.TemplateEngine.Core.sln
1920
- name: Build
20-
run: dotnet build --configuration Release --no-restore
21-
- name: Publish to NuGet
22-
uses: brandedoutcast/publish-nuget@v2
23-
with:
24-
PROJECT_FILE_PATH: MbSoftLab.TemplateEngine.Core/MbSoftLab.TemplateEngine.Core.csproj
25-
PACKAGE_NAME: Core
26-
VERSION_REGEX: '^\s*<PackageVersion>(.*)<\/PackageVersion>\s*$'
27-
TAG_FORMAT: 'v*'
28-
NUGET_KEY: ${{secrets.NUGET_API_KEY}}
21+
run: dotnet build MbSoftLab.TemplateEngine.Core.sln --configuration Release --no-restore
22+
- name: Pack
23+
run: dotnet pack MbSoftLab.TemplateEngine.Core/MbSoftLab.TemplateEngine.Core.csproj --configuration Release --no-restore -o ./artifacts
24+
- name: Push to NuGet
25+
run: dotnet nuget push ./artifacts/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate

CHANGELOG.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Changelog
2+
3+
Alle wichtigen Änderungen an diesem Projekt werden in dieser Datei dokumentiert.
4+
5+
Das Format basiert auf [Keep a Changelog](https://keepachangelog.com/de/1.0.0/),
6+
und dieses Projekt folgt [Semantic Versioning](https://semver.org/lang/de/).
7+
8+
## [Unveröffentlicht]
9+
10+
### Geändert
11+
- Veröffentlichungsprozess aktualisiert: NuGet-Publish-Aktion durch `dotnet pack` und `dotnet nuget push` ersetzt (Commit: 5c37e68)
12+
13+
## [1.0.8-preview2] - Stand: Commit 5c37e68
14+
15+
### Hinzugefügt
16+
- RazorTemplateEngine für komplexe HTML-Templates mit Razor-Syntax
17+
- Unterstützung für Razor-Templates mit der `RazorTemplateEngine<T>` Klasse
18+
- `ITemplateEngine<T>` Interface für beide Template-Engine-Implementierungen
19+
- `ITemplateEngineConfig<T>` Interface und `TemplateEngineConfig<T>` Klasse für Konfiguration
20+
- Erweiterungsmethoden `CreateStringFromTemplateWithJson<T>` und `LoadTemplateFromFile<T>`
21+
- Demo-Projekt mit Razor-Template-Beispielen
22+
- Unterstützung für parameterlose öffentliche Methoden im TemplateDataModel (Syntax: `${MethodName()}`)
23+
24+
### Funktionen
25+
- Einfacher String-basierter Template-Engine (`TemplateEngine` und `TemplateEngine<T>`)
26+
- Razor-basierter Template-Engine (`RazorTemplateEngine<T>`)
27+
- Anpassbare Delimiter (Standard: `${` und `}`)
28+
- Konfigurierbare NULL-Wert-Behandlung (Standard: "NULL")
29+
- Kultur-spezifische Formatierung für Datum und Zahlen (Standard: en-US)
30+
- JSON-Deserialisierung für TemplateDataModel
31+
- Laden von Templates aus Dateien
32+
33+
### Unterstützte Datentypen
34+
- Primitive Typen: String, Byte, Short, UShort, Long, ULong, SByte, Char
35+
- Numerische Typen: Int16, Int32, Int64, UInt16, UInt32, UInt64, Decimal, Double
36+
- Weitere Typen: DateTime, Boolean
37+
38+
### Technische Details
39+
- Target Framework: .NET 8.0
40+
- Assembly Version: 1.0.8.2
41+
- Package Version: 1.0.8-preview2
42+
- Abhängigkeit: RazorEngineCore 2020.10.1
43+
44+
### Build und CI/CD
45+
- GitHub Actions Workflows für Build (Develop und Master Branch)
46+
- GitHub Actions Workflow für Release und NuGet-Veröffentlichung
47+
- Automatische NuGet-Package-Generierung beim Build
48+
49+
---
50+
51+
## Versions-Historie (Zusammenfassung)
52+
53+
Die Version 1.0.8-preview2 ist die aktuelle Entwicklungsversion mit Razor-Template-Unterstützung.
54+
55+
**Commit-Referenz für diese Dokumentation:** 5c37e68 (Basis-Commit für Dokumentation)

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2021 MbSoftLab
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

MbSoftLab.TemplateEngine.Core.Razor/Documentation.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net8.0</TargetFramework>
5+
<AssemblyVersion>1.1.0.0</AssemblyVersion>
6+
<FileVersion>1.1.0.0</FileVersion>
7+
<Version>1.1.0</Version>
8+
<PackageVersion>1.1.0-preview</PackageVersion>
9+
<Description>Razor-enabled extension for MbSoftLab.TemplateEngine.Core providing RazorTemplateEngine.</Description>
10+
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
11+
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
12+
<PackageTags>Template Engine Razor RazorEngineCore Html</PackageTags>
13+
<PackageId>MbSoftLab.TemplateEngine.Core.Razor</PackageId>
14+
<Company>MbSoftLab</Company>
15+
<Authors>MbSoftLab</Authors>
16+
<PackageLicenseExpression>MIT</PackageLicenseExpression>
17+
<Copyright>© 2021 - 2025 MbSoftLab</Copyright>
18+
<PackageIcon>MbSoftLabLogo.png</PackageIcon>
19+
<PackageProjectUrl>https://github.com/mbsoftlab/MbSoftLab.TemplateEngine.Core</PackageProjectUrl>
20+
<RepositoryUrl>https://github.com/mbsoftlab/MbSoftLab.TemplateEngine.Core</RepositoryUrl>
21+
<RepositoryType>Git</RepositoryType>
22+
<DocumentationFile>Documentation.xml</DocumentationFile>
23+
</PropertyGroup>
24+
25+
<ItemGroup>
26+
<PackageReference Include="RazorEngineCore" Version="2020.10.1" />
27+
</ItemGroup>
28+
29+
<ItemGroup>
30+
<ProjectReference Include="../MbSoftLab.TemplateEngine.Core/MbSoftLab.TemplateEngine.Core.csproj" />
31+
<None Include="../MbSoftLab.TemplateEngine.Core/MbSoftLabLogo.png">
32+
<Pack>True</Pack>
33+
<PackagePath></PackagePath>
34+
</None>
35+
</ItemGroup>
36+
37+
</Project>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# MbSoftLab.TemplateEngine.Core.Razor
2+
3+
Optionales Erweiterungspaket für MbSoftLab.TemplateEngine.Core, das die `RazorTemplateEngine<T>` bereitstellt.
4+
5+
## Installation
6+
7+
```bash
8+
# .NET CLI
9+
dotnet add package MbSoftLab.TemplateEngine.Core.Razor
10+
11+
# Oder Projekt-Referenz (Monorepo)
12+
dotnet add <IhrProjekt>.csproj reference MbSoftLab.TemplateEngine.Core.Razor/MbSoftLab.TemplateEngine.Core.Razor.csproj
13+
```
14+
15+
## Verwendung
16+
17+
```csharp
18+
using MbSoftLab.TemplateEngine.Core;
19+
20+
public class Person : TemplateDataModel<Person>
21+
{
22+
public string FirstName { get; set; }
23+
}
24+
25+
var person = new Person { FirstName = "Anna" };
26+
27+
var engine = new RazorTemplateEngine<Person>();
28+
engine.TemplateString = "<h1>@Model.FirstName</h1>";
29+
string html = engine.CreateStringFromTemplate(person);
30+
```
31+
32+
Hinweis: `TemplateDataModel<T>` ist nun eine einfache Klasse im Core (ohne Razor-Basis). Die Razor-Engine erhält intern `Model` als Datenmodell (`template.Run(TemplateDataModel?.Model)`).
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
using RazorEngineCore;
2+
using System;
3+
using System.ComponentModel;
4+
using System.Globalization;
5+
6+
namespace MbSoftLab.TemplateEngine.Core;
7+
8+
public class RazorTemplateEngine<T> : ITemplateEngine<T> where T : TemplateDataModel<T>
9+
{
10+
public string CloseingDelimiter { get { Console.WriteLine($"RazorTemplateEngine has no {nameof(CloseingDelimiter)}"); return ""; } set => Console.WriteLine($"Can not set {nameof(CloseingDelimiter)} for RazorTemplateEngine"); }
11+
ITemplateEngineConfig<T> _config;
12+
public ITemplateEngineConfig<T> Config
13+
{
14+
get => _config;
15+
set
16+
{
17+
_config = value;
18+
this.NullStringValue = _config.NullStringValue;
19+
this.OpeningDelimiter = _config.OpeningDelimiter;
20+
this.CloseingDelimiter = _config.CloseingDelimiter;
21+
this.TemplateDataModel = _config.TemplateDataModel;
22+
this.TemplateString = _config.TemplateString;
23+
this.CultureInfo = _config.CultureInfo;
24+
}
25+
}
26+
public CultureInfo CultureInfo { get { Console.WriteLine($"{nameof(RazorTemplateEngine<T>)} can not maipulate {nameof(CultureInfo)}"); return null; } set => Console.WriteLine($"{nameof(RazorTemplateEngine<T>)} can not maipulate {nameof(CultureInfo)}"); }
27+
28+
public string NullStringValue
29+
{
30+
get => "String.Empty";
31+
set { Console.WriteLine(new WarningException($"{nameof(RazorTemplateEngine<T>)} can not maipulate {nameof(NullStringValue)}").Message); }
32+
}
33+
34+
public string OpeningDelimiter
35+
{
36+
get
37+
{
38+
Console.WriteLine(new WarningException($"RazorTemplateEngine has no {nameof(OpeningDelimiter)}").Message);
39+
return "";
40+
}
41+
set
42+
{
43+
Console.WriteLine(new WarningException($"Can not set {nameof(OpeningDelimiter)} for RazorTemplateEngine").Message);
44+
}
45+
}
46+
47+
public T TemplateDataModel { get; set; }
48+
public string TemplateString { get; set; }
49+
IRazorEngine razorEngine;
50+
51+
public RazorTemplateEngine(IRazorEngine razorEngine)
52+
{
53+
this.razorEngine = razorEngine;
54+
}
55+
56+
public RazorTemplateEngine()
57+
{
58+
razorEngine = new RazorEngine();
59+
}
60+
61+
public RazorTemplateEngine(T dataModel, string templateString)
62+
{
63+
razorEngine = new RazorEngine();
64+
TemplateDataModel = dataModel;
65+
TemplateString = templateString;
66+
}
67+
68+
public string CreateStringFromTemplate(string csHtmlTemplate = null)
69+
{
70+
TemplateString = csHtmlTemplate ?? TemplateString;
71+
IRazorEngineCompiledTemplate template = razorEngine.Compile(TemplateString);
72+
73+
string result = template.Run(TemplateDataModel);
74+
return result;
75+
}
76+
77+
public string CreateStringFromTemplate(T templateDataModel)
78+
{
79+
TemplateDataModel = templateDataModel;
80+
return CreateStringFromTemplate();
81+
}
82+
83+
public string CreateStringFromTemplate(T templateDataModel, string csHtmlTemplate)
84+
{
85+
TemplateDataModel = templateDataModel;
86+
TemplateString = csHtmlTemplate;
87+
return CreateStringFromTemplate();
88+
}
89+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"DummyStringProp1": "DummyStringProp1Value",
3+
"DummyIntProp1": 1,
4+
"DummBoolProp1": true,
5+
"DummyBoolQProp1": true,
6+
"DummyDoubleProp1": 1.75,
7+
"DummyDateTimeProp1": "2020-01-01T00:00:00",
8+
"DummyInt64Prop": 1234567,
9+
"DummyUInt16": 8,
10+
"DummyInt16": -8,
11+
"DummyDecimalProp": 55,
12+
"DummyCharProp": "c",
13+
"DummyByteProp": 255,
14+
"DummySByteProp": -5
15+
}

0 commit comments

Comments
 (0)