Don't use `$post` global, use functions instead

Fixes #1011, props @jeherve
Whitespace -- tabs > spaces