Add template algorithm for converting the tree of nodes to html elments.

Uses a recursive function right now even though it probably shouldn't due to the danger
of running out of memory on the stack.