You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This project is a C# implementation of Go's template engine using ANTLR for parsing. It began as an experiment to see whether OpenAI Codex could port the Go implementation to .NET. Claude.AI helped with explanations and refinements along the way.
6
-
The source code in this repository was largely produced by Codex with input
7
-
from Claude.AI, and this README itself was also authored using Codex.
5
+
text/template is a C# implementation of Go's template engine using ANTLR for parsing. It began as an experiment to see whether OpenAI Codex could port the Go implementation to .NET. Claude AI helped with explanations and refinements along the way, but the prompts were from my own knowledge of Antlr and grammars, and obviously C#.
6
+
7
+
It ported the Go code to begin with, but then I realised Antlr would probably be a safer and more readable alternative than a straight Go ---> C# port.
8
+
9
+
This README itself was also largely authored using Codex. Internally the engine uses an ANTLR-generated lexer and parser.
This library now contains virtually all functionality from the original Go text/template package. Parse templates with `Template.New("name").Parse(text)` and execute them with `Execute` to perform variable substitution, loops and conditionals. Internally the engine uses an ANTLR-generated lexer and parser.
16
+
This library now contains virtually all functionality from the original Go text/template package.
@@ -197,21 +199,25 @@ See the unit tests for more examples covering loops, conditionals and range expr
197
199
198
200
## Benchmark Results
199
201
200
-
Thefollowingmicrobenchmarkswererunusing [BenchmarkDotNet](https://benchmarkdotnet.org/) on .NET 9.0. Each benchmark renders the same short template:
202
+
Thefollowingbenchmarkswererunusing [BenchmarkDotNet](https://benchmarkdotnet.org/) on .NET 9.0, `cpu: AMD Ryzen 7 5700X 8-Core Processor`. Each benchmark renders the same short template:
201
203
202
204
```text
203
205
Hello {{ .Name }}! {{ range .Items }}{{ . }} {{ end }}
0 commit comments