Heist in 60 Seconds

A template system is a bridge between static data (templates) and dynamic data.

Heist is a template system bridging HTML templates and Haskell code.

A splice is code that Heist binds to an HTML tag.

Every time the tag appears in a template, Heist runs the splice bound to that tag and passes the tag (including its attributes and its children) as input to the splice.

A splice's output is a list of tags that get substituted into the template in place of the original input tag.

Splices can be thought of as functions that can be called from templates to get dynamic data.

Splices can pass this dynamic data back to templates by (temporarily) binding new splices.

<bind> is a tag you can use in your templates to create new splices on the fly.

<apply> is a tag that lets you insert one template into another.


A more in-depth tutorial is here.

Comments

Anonymous said…
I really like heist and the way that it is shaping up - it's simple and very effective in a way that JSP isn't !

I know it's early days but performance of heist looks a problem at the moment. As an example I have a template that takes around 100ms to serve from JSP and it takes around 250ms in Heist / Snap and I know that snap is not taking anything like that time because a static file of the same content takes less than 60ms. That was on 0.5, on 0.5.1 it has increased to over 2 seconds ! Maybe it is my setup but 0.5.1 has something seriously wrong with it but I think 0.5 could also use some optimisation.

Andrew
mightybyte said…
Interesting. I haven't seen anything quite that extreme. If you can post the details of your example or email them to me I'll definitely take a look at it.
mightybyte said…
I did some tests and it looks like the slowdown is caused by the new head merging feature introduced in Heist 0.5.1. I just released 0.5.1.1 which turns this feature off by default, so if you upgrade to that version you should get back to normal page load times. The code is still there so you can still use the feature by binding the html splice. Thanks for the heads-up.

Popular posts from this blog

A Hopefully Fair and Useful Comparison of Haskell Web Frameworks

Setting Up A Private Nix Cache

Dependent Types are a Runtime Maybe