Faultd.

Journal of a software engineer.

Introducing HTMT

14 October, 2024

Woah, where have I been? Well, since my last post I've gotten a new job at Novater that I'm really enjoying, and I've also been busy working on my first ever C# project: HTMT or Hypertext Markup Templating. It's a templating language that is a superset of HTML/XML, and looks a little something like this:

<!DOCTYPE html>
<html>
    <head>
        <title x:inner-text="{title}"></title>
    </head>
    <body>
        <h1 x:inner-text="{title}"></h1>
        
        <div class="posts" x:if="posts">
            <div x:for="posts" x:as="post">
                <h2>
                    <a x:href="/blog/{post.url}" x:inner-text="{post.title}"></a>
                </h2>
                <div x:inner-html="{post.body}"></div>
            </div>
        </div>
    </body>
</html>

I was re-writing Tobey in C# and wanted to use a templating language, but quickly discovered that there seem to be no templating languages that support trimming and native AOT compilation, so I decided to make one.

Another goal of mine with this was to eliminate the frustration I've had with many other templating languages - namely that they quite often lack good editor support or syntax highlighting, and because HTMT works by using regular HTML attributes, you won't need any additional syntax highlighting.

There's still a bunch I want to achieve with this, such as partials, more complex conditionals, and more, but I'm really happy with how it's turning out.

You can read more about HTMT on GitHub or NuGet.


You may be wondering why C#? And what happened to C++? Well, while I really enjoy C++, I wanted to set my main focus on something that is actually employable and also a joy to write - with great tooling, ecosystem and a huge array of things you can do with it, C# fits that bill perfectly. Hence, why I've been re-writing Tobey in C# and also building HTMT in C#. As part of the Tobey re-write, I will soon publish another library as well - a Markdown parser, naturally also one that supports trimming and native AOT compilation.