use tpl_toc to determine if TOC should be shown, to affect layout

tpl_toc returns NULL if there is no TOC to show so we can change the
grid layout later. Not sure if we could save the tpl_toc return value
then use it later instead of regenerating again to save a bit of time..
Merge pull request #10 from celsworth/intelligent_toc

use tpl_toc to determine if TOC should be shown