Skip to content

Commit 51b02ca

Browse files
committed
2 parents 1b73a45 + b0e602f commit 51b02ca

File tree

1 file changed

+33
-20
lines changed

1 file changed

+33
-20
lines changed

README.md

Lines changed: 33 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* Windows / Linux
88
* Publish as single file supported
99
* Thread safe
10+
* Template debugging
1011

1112
[![NuGet](https://img.shields.io/nuget/dt/RazorEngineCore.svg?style=flat-square)](https://www.nuget.org/packages/RazorEngineCore)
1213
[![NuGet](https://img.shields.io/nuget/v/RazorEngineCore.svg?style=flat-square)](https://www.nuget.org/packages/RazorEngineCore)
@@ -26,8 +27,11 @@ Install-Package RazorEngineCore
2627

2728

2829
## Articles
29-
* [CodeProject: Building String Razor Template Engine with Bare Hands](https://www.codeproject.com/Articles/5260233/Building-String-Razor-Template-Engine-with-Bare-Ha)
30-
* [Razor syntax reference](https://docs.microsoft.com/en-us/aspnet/core/mvc/views/razor?view=aspnetcore-6.0)
30+
* [🚀 Piotr Bakun: How to make PDF invoice with Playwright.NET](https://bakson.dev/2022/11/10/razor-engine-core.html)
31+
* [🚀 Christian Schou: How to send email with MailKit](https://blog.christian-schou.dk/send-emails-with-asp-net-core-with-mailkit/)
32+
* [🚀 Dave Glick: Difference between RazorEngineCore, RazorLight and Statiq, Send email using SendGrid API](https://www.twilio.com/blog/render-emails-using-razor-templating)
33+
* [🧑‍🎓 CodeProject: Building String Razor Template Engine with Bare Hands](https://www.codeproject.com/Articles/5260233/Building-String-Razor-Template-Engine-with-Bare-Ha)
34+
* [📕 Razor syntax reference](https://docs.microsoft.com/en-us/aspnet/core/mvc/views/razor?view=aspnetcore-6.0)
3135

3236
## Wiki
3337
* [Package comparison: RazorEngineCore / RazorLight / RazorEngine.NetCore](https://github.com/adoconnection/RazorEngineCore/wiki/Package-comparison)
@@ -38,6 +42,8 @@ Install-Package RazorEngineCore
3842
* [Switch from RazorEngine cshtml templates](https://github.com/adoconnection/RazorEngineCore/wiki/Switch-from-RazorEngine-cshtml-templates)
3943
* [Azure Functions FileNotFoundException workaround](https://github.com/adoconnection/RazorEngineCore/wiki/Azure-Functions-FileNotFoundException-workaround)
4044
* [@Html implementation example](https://github.com/adoconnection/RazorEngineCore/wiki/@Html-implementation-example)
45+
* [Debugging](https://github.com/adoconnection/RazorEngineCore/wiki/Debugging)
46+
4147

4248
## Extensions
4349
* [wdcossey/RazorEngineCore.Extensions](https://github.com/wdcossey/RazorEngineCore.Extensions)
@@ -89,6 +95,24 @@ string result = template.Run(instance =>
8995
Console.WriteLine(result);
9096
```
9197

98+
#### Debugging
99+
Compile template with ```IncludeDebuggingInfo()``` option and call ```EnableDebugging()``` before running template. If template was compiled with ```IncludeDebuggingInfo()``` option, saving and loading will keep original template source code and pdb.
100+
```cs
101+
IRazorEngineCompiledTemplate template2 = razorEngine.Compile(templateText, builder =>
102+
{
103+
builder.IncludeDebuggingInfo();
104+
});
105+
106+
template2.EnableDebugging(); // optional path to output directory
107+
108+
string result = template2.Run(new
109+
{
110+
Title = "Welcome"
111+
});
112+
```
113+
Place ```@{ Breakpoint(); }``` anywhere in template to stop at.
114+
115+
92116
#### Save / Load compiled templates
93117
Most expensive task is to compile template, you should not compile template every time you need to run it
94118
```cs
@@ -206,29 +230,18 @@ IRazorEngineCompiledTemplate compiledTemplate = razorEngine.Compile(templateText
206230
});
207231

208232
string result = compiledTemplate.Run(new { name = "Hello" });
209-
```
210-
211-
#### Debugging templates
212-
In the builder options, set GeneratePdbStream to true, and set the TemplateFilename.
213-
```cs
214-
razorEngine.Compile(templateSource, builder =>
215-
{
216-
builder.Options.GeneratePdbStream = true;
217-
builder.Options.TemplateFilename = "TemplateFilename.cshtml"
218-
});
219-
```
220-
Your debugger will popup a window asking you to find the source file, after which you can step through as normal.
221-
222-
To set a breakpoint add this line in a code block in the template.
223-
```cs
224-
System.Diagnostics.Debugger.Break();
225-
```
233+
``
226234

227235
#### Credits
228236
This package is inspired by [Simon Mourier SO post](https://stackoverflow.com/a/47756437/267736)
229237
230238

231239
#### Changelog
240+
* 2023.11.1
241+
* Template debugging 🚀 PR#111 (thanks [@shehrozeee](https://github.com/shehrozeee) and [@TheAtomicOption](https://github.com/TheAtomicOption))
242+
* Add CancellationToken overloads to Compile methods PR#134 (thanks [@daviddotcs](https://github.com/daviddotcs))
243+
* Package license information #133
244+
* Code cleanup
232245
* 2022.8.1
233246
* Proper namespace handling for nested types and types without namespace #113 (thanks [@Kirmiir](https://github.com/Kirmiir))
234247
* 2022.7.6
@@ -286,4 +299,4 @@ This package is inspired by [Simon Mourier SO post](https://stackoverflow.com/a/
286299
* Html attribute rendering tests
287300

288301
## Supported by
289-
<img src="https://resources.jetbrains.com/storage/products/company/brand/logos/jb_square.svg" />
302+
[<img src="https://259506.selcdn.ru/sites-static/site609131/d7defb1c-34d5-4719-8dd8-5c0395badfeb/d7defb1c-34d5-4719-8dd8-5c0395badfeb-2809062.png" />](https://limetime.io)

0 commit comments

Comments
 (0)