This is a small example demonstrating how to implement looping template tags ("splices") with the Heist template system that is the default with the Snap Framework.
The src/Site.hs
file contains the interesting bits:
-
The
loop
handler which simply renders theloop.tpl
template with theloopSplice
splice function; and -
The
loopSplice
splice function which implements the<loop>
template tag.This new tag has two attributes --
from
andto
-- which specify the initial and final values for the counter. The body of the tag is repeated once for each step between thefrom
andto
values with the<step/>
tag, if it is in the body, replaced with the current value.