JTML May 27, 2026
I made a little template builder type of application to break up HTML files into smaller consumable chunks
View it at github.com/jasontconnell/jtml !
Basically, I don't like writing HTML. Or Go HTML templates. Basically with Go and HTML you have to write the entire HTML file wrapper, starting with <html> and closing with </html>.
This becomes pretty tiresome. There may be another way but I will put some time looking into it sometime in the future. That side idea is basically, the parameter to render a template takes a string for the name, and I wonder if you can pass a variable there instead. So it'd look like this…
{{ define “Main” }}
<html>
{{ template .Template .Data }}
</html>
{{ end }}
But anyway, I wanted a different way and thought it would be neat to write a new parser type of deal. This is the syntax that I wanted, because I didn't want to keep track of close tags and stuff like that.
#jtml
#head
#body body-css-class
#h1 Hello, World!
#footer
And that's it! I'd define partials as underscore and the name, like _head.jtml where here, #head will inject the _head.jtml contents. In order to handle the nesting properly, for instance in #body, the body jtml file will define @open and @close directives which contains the contents to write out before and after that section is rendered.
This can be used to build regular html files as well as Go template files. For example, in _jtml.jtml I define a parameter to allow it to define what the template should be called, in Go template land.
I currently rewrote altarschedule.com in the new template engine but I haven't deployed that version yet. I have tested pretty much every piece of functionality though after I made the change.
I'll look into that alternative way to handle templates, but not too urgently because this is a pretty good solution and what I wanted :) I plan to update it in the near future to add conditionals and named variables to give a little bit better control over how they work.