diff --git a/ExampleAppNET8/ExampleAppNET8.csproj b/ExampleAppNET8/ExampleAppNET8.csproj new file mode 100644 index 0000000..4571072 --- /dev/null +++ b/ExampleAppNET8/ExampleAppNET8.csproj @@ -0,0 +1,21 @@ + + + + Exe + net8.0 + + + + + + + + + Always + + + Always + + + + diff --git a/ExampleAppNET8/Program.cs b/ExampleAppNET8/Program.cs new file mode 100644 index 0000000..4d7ae7c --- /dev/null +++ b/ExampleAppNET8/Program.cs @@ -0,0 +1,58 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Reflection; +using System.Runtime.InteropServices; +using RazorEngineCore; + +namespace ExampleAppNET5 +{ + + class Program + { + static void Main(string[] args) + { + IRazorEngine razorEngine = new RazorEngine(); + IRazorEngineCompiledTemplate template1 = razorEngine.Compile("Hello

@Model.Name

"); + + string result = template1.Run(new + { + Name = "Alex" + }); + + Console.WriteLine(result); + } + + + static void ReadFromFileAndRun() + { + IRazorEngine razorEngine = new RazorEngine(); + string templateText = File.ReadAllText("template2.cshtml"); + + IRazorEngineCompiledTemplate template2 = razorEngine.Compile(templateText, builder => + { + builder.IncludeDebuggingInfo(); + }); + + if (!Directory.Exists("Temp")) + { + Directory.CreateDirectory("Temp"); + } + + template2.EnableDebugging("Temp"); + + string result = template2.Run(new + { + Name = "Alexander", + Items = new List() + { + "item 1", + "item 2" + } + }); + + Console.WriteLine(result); + Console.ReadKey(); + } + } +} diff --git a/ExampleAppNET8/template1.cshtml b/ExampleAppNET8/template1.cshtml new file mode 100644 index 0000000..eb7654e --- /dev/null +++ b/ExampleAppNET8/template1.cshtml @@ -0,0 +1,24 @@ +Hello @Model.Name + +@foreach(var item in @Model.Items) +{ +
- @item
+} + +
+ + + @{ RecursionTest(3); } + + +@{ + void RecursionTest(int level){ + if (level <= 0) + { + return; + } + +
LEVEL: @level
+ @{ RecursionTest(level - 1); } + } +} \ No newline at end of file diff --git a/ExampleAppNET8/template2.cshtml b/ExampleAppNET8/template2.cshtml new file mode 100644 index 0000000..9b0c898 --- /dev/null +++ b/ExampleAppNET8/template2.cshtml @@ -0,0 +1,24 @@ +
+

Hello

+ + @{ Breakpoint(); } + + @if (Model != null) + { +

Hello @Model

+ } + +

111

+ + @if (Model != null) + { +

Hello @Model

+ } + +

111

+ + @if (Model != null) + { +

Hello @Model

+ } +
\ No newline at end of file diff --git a/RazorEngineCore.Tests/RazorEngineCore.Tests.csproj b/RazorEngineCore.Tests/RazorEngineCore.Tests.csproj index 6a28b1e..4c65ef9 100644 --- a/RazorEngineCore.Tests/RazorEngineCore.Tests.csproj +++ b/RazorEngineCore.Tests/RazorEngineCore.Tests.csproj @@ -7,9 +7,9 @@ - - - + + + diff --git a/RazorEngineCore.sln b/RazorEngineCore.sln index d181165..22b2125 100644 --- a/RazorEngineCore.sln +++ b/RazorEngineCore.sln @@ -18,6 +18,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ExampleAppNET472", "Example EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ExampleAppNET5", "ExampleAppNET5\ExampleAppNET5.csproj", "{B19C090A-4EC1-441D-B702-ADD2ECA79198}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ExampleAppNET8", "ExampleAppNET8\ExampleAppNET8.csproj", "{9E5835E0-F768-4ADE-9A1F-61FE6B411B8F}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -44,6 +46,10 @@ Global {B19C090A-4EC1-441D-B702-ADD2ECA79198}.Debug|Any CPU.Build.0 = Debug|Any CPU {B19C090A-4EC1-441D-B702-ADD2ECA79198}.Release|Any CPU.ActiveCfg = Release|Any CPU {B19C090A-4EC1-441D-B702-ADD2ECA79198}.Release|Any CPU.Build.0 = Release|Any CPU + {9E5835E0-F768-4ADE-9A1F-61FE6B411B8F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9E5835E0-F768-4ADE-9A1F-61FE6B411B8F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9E5835E0-F768-4ADE-9A1F-61FE6B411B8F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9E5835E0-F768-4ADE-9A1F-61FE6B411B8F}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/RazorEngineCore/RazorEngineCore.csproj b/RazorEngineCore/RazorEngineCore.csproj index 90fa169..11c2eb9 100644 --- a/RazorEngineCore/RazorEngineCore.csproj +++ b/RazorEngineCore/RazorEngineCore.csproj @@ -21,8 +21,8 @@ true - - + +