RFC: templette + templette-markdown

Back in February, I had an idea for a templating language like MDX, except being able to evaluate + interpolate Haskell expressions instead of Javascript. I finally got around to finishing it up, and got the prototype working!

My eventual goal was to also create a static site generator built on top of this (think hakyll, but opinionated + more batteries included); we’ll see if I get around to that aspect. But templette was the first step towards that.

It’s not on Hackage yet, to avoid name squatting on two package names, but if there’s interest, I could push it up any time. Also, if you’re interested in contributing, there’s certainly lots to do (anyone looking for practice on a small package??). Just let me know and we can coordinate.

Here’s a quick preview (but a bigger example is provided in the README):

  • input.ths-md:
{$setup}
double :: Int -> Int
double = (* 2)
{$end}

2 * 2 = {show $ 2 * 2}
  • templette-markdown --render input.ths-md:
2 * 2 = 4
9 Likes

Looks nice! I’ve also wanted to create a package to insert Haskell expressions into text for quite some time. My use case would be for generating documents where I need to compute some data and show it in tables and diagrams.

I’ll head on over to GitHub and see if I can contribute somewhere. I also have some new features in mind, so I do not know if I will actually reduce the amount of issues :grin:.

2 * 2 = {show $ 2 * 2}

Perhaps, show should be inserted automatically at processing time for better UX.

@artem yup! Work in progress :slight_smile:

@simon no worries, any help would be great!

2 Likes